예제 #1
0
/*------------------------------------------------------------------------*/
int do_single_update(char *tmpdir, char *uuid, char *device)
{
	char path[256];
	int ret;

	snprintf(path,255,"%s/%s",tmpdir,"update.scr");
	if (generate_script(path, tmpdir, uuid, device, username, password))
		return -1;
//  	puts(script);

	printf("Upload update... ");
	fflush(stdout);

	ret=run_ftp(tmpdir, script, 600,"");
	if (ret)
		return ret;

	printf("check result... \n");
	fflush(stdout);

	if (check_state_file(tmpdir))
		return -1;

#if 1
	if (!no_reboot) {
		printf("Issue Reboot... ");
		fflush(stdout);
		ret=do_reboot(tmpdir, uuid, device, username, password);
		if (!ret) 
			return ret;
	}
#endif
	return 0;
}
예제 #2
0
파일: main.c 프로젝트: cherry-wb/quietheart
void dialog_ok(GtkWidget *widget, gpointer data)
{
	const gchar *title = (const gchar *)data;
	if(!g_strcasecmp(title, item_labels[2]))
		do_reboot();
	else if(!g_strcasecmp(title, item_labels[3]))
		do_shutdown();					

}
/**************************************************************************
*  Reboot State
**************************************************************************/
void handle_reboot (void)
{
    // check if device Is ready to use
    g_boot_dev.dev_wait_ready ();
    DM_TIME_TOTAL_END;
#if DM_TIME_ANALYSIS
    dump_time_analysis ();
#endif
    mt_usb_disconnect_internal();
    do_reboot (0);
}
예제 #4
0
/*------------------------------------------------------------------------*/
int do_all_reboot(char **uuids, int num_uuids, char *device)
{
	int n,ret=0;

	for(n=0;n<num_uuids;n++) {
		if (!uuids[n])
			continue;
		printf("UUID %s: Issue Reboot... ",uuids[n]);
		fflush(stdout);
		ret=do_reboot("/tmp", uuids[n], device, username, password);
		if (!ret)
			printf("Reboot done\n");
		else
			printf("Reboot failed (ret=%i)\n",ret);
	}
	return ret;
}
예제 #5
0
파일: main.c 프로젝트: elisescu/multirom
int main(int argc, char *argv[])
{
    int i;
    for(i = 1; i < argc; ++i)
    {
        if(strcmp(argv[i], "-v") == 0)
        {
            printf("%d%s\n", VERSION_MULTIROM, VERSION_DEV_FIX);
            return 0;
        }
    }

    srand(time(0));
    klog_init();

    // output all messages to dmesg,
    // but it is possible to filter out INFO messages
    klog_set_level(6);

    ERROR("Running MultiROM v%d%s\n", VERSION_MULTIROM, VERSION_DEV_FIX);

    int exit = multirom();

    if(exit >= 0)
    {
        if(exit & EXIT_REBOOT_MASK)
        {
            do_reboot(exit);
            return 0;
        }

        if(exit & EXIT_KEXEC)
        {
            do_kexec();
            return 0;
        }

        // indicates trampoline to keep /realdata mounted
        if(!(exit & EXIT_UMOUNT))
            close(open(KEEP_REALDATA, O_WRONLY | O_CREAT, 0000));
    }

    vt_set_mode(0);

    return 0;
}
예제 #6
0
파일: main.c 프로젝트: cherry-wb/quietheart
void item_press(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
	ITEM_IMG *item_img = (ITEM_IMG *)data;
	gint index = item_img->index;

	switch(index)
	{
	case REBOOT:
		do_reboot();
		break;
	case STANDBY:
		standby();
		break;
	case SHUTDOWN:
		do_shutdown();
		break;
	case CANCEL:
		cancel();
		break;
	}
}
예제 #7
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QDialog w;
    w.setWindowTitle("Reboot into:");
    QVBoxLayout layout;
    efi_init();
    reboot_init();
    uint16_t *data;
    int l = boot_entry_list(&data);
    for (int i = 0; i < l; i++) {
        QPushButton *button = new QPushButton(QString(boot_entry_name(data[i])));
        layout.addWidget(button);
        button->connect(button, &QPushButton::clicked, [=]() {
            set_boot_next(data[i]);
            do_reboot();
        });
    }
    w.setLayout(&layout);
    w.show();
    return a.exec();
}
예제 #8
0
파일: main.c 프로젝트: black3r/efireboot
int main()
{    
    uint16_t *data;
    int l, i, c;
    data = NULL;
    efi_init(); // Perform all tasks needed to access EFI functions
    reboot_init(); // Perform all tasks needed to access Reboot functions
    l = boot_entry_list(&data);
    for (i = 0; i < l; i++) {
        printf("%d: %s\n", i, boot_entry_name(data[i]));
    }
    printf("Input your choice: ");
    scanf("%d", &c);
    if (c < 0 || c >= l) {
        printf("ERROR: Invalid choice\n");
        exit(-1);
    }
    set_boot_next(data[c]);
    printf("Set next boot target to: %s\n", boot_entry_name(data[c]));
    do_reboot();

    return 0;
}
예제 #9
0
파일: mtd.c 프로젝트: AlexKust/openwrt
int main (int argc, char **argv)
{
	int ch, i, boot, imagefd = 0, force, unlocked;
	char *erase[MAX_ARGS], *device = NULL;
	char *fis_layout = NULL;
	size_t offset = 0, part_offset = 0, dump_len = 0;
	enum {
		CMD_ERASE,
		CMD_WRITE,
		CMD_UNLOCK,
		CMD_JFFS2WRITE,
		CMD_FIXTRX,
		CMD_FIXSEAMA,
		CMD_VERIFY,
		CMD_DUMP,
	} cmd = -1;

	erase[0] = NULL;
	boot = 0;
	force = 0;
	buflen = 0;
	quiet = 0;
	no_erase = 0;

	while ((ch = getopt(argc, argv,
#ifdef FIS_SUPPORT
			"F:"
#endif
			"frnqe:d:s:j:p:o:l:")) != -1)
		switch (ch) {
			case 'f':
				force = 1;
				break;
			case 'r':
				boot = 1;
				break;
			case 'n':
				no_erase = 1;
				break;
			case 'j':
				jffs2file = optarg;
				break;
			case 's':
				errno = 0;
				jffs2_skip_bytes = strtoul(optarg, 0, 0);
				if (errno) {
						fprintf(stderr, "-s: illegal numeric string\n");
						usage();
				}
				break;
			case 'q':
				quiet++;
				break;
			case 'e':
				i = 0;
				while ((erase[i] != NULL) && ((i + 1) < MAX_ARGS))
					i++;

				erase[i++] = optarg;
				erase[i] = NULL;
				break;
			case 'd':
				jffs2dir = optarg;
				break;
			case 'p':
				errno = 0;
				part_offset = strtoul(optarg, 0, 0);
				if (errno) {
					fprintf(stderr, "-p: illegal numeric string\n");
					usage();
				}
				break;
			case 'l':
				errno = 0;
				dump_len = strtoul(optarg, 0, 0);
				if (errno) {
					fprintf(stderr, "-l: illegal numeric string\n");
					usage();
				}
				break;
			case 'o':
				errno = 0;
				offset = strtoul(optarg, 0, 0);
				if (errno) {
					fprintf(stderr, "-o: illegal numeric string\n");
					usage();
				}
				break;
#ifdef FIS_SUPPORT
			case 'F':
				fis_layout = optarg;
				break;
#endif
			case '?':
			default:
				usage();
		}
	argc -= optind;
	argv += optind;

	if (argc < 2)
		usage();

	if ((strcmp(argv[0], "unlock") == 0) && (argc == 2)) {
		cmd = CMD_UNLOCK;
		device = argv[1];
	} else if ((strcmp(argv[0], "erase") == 0) && (argc == 2)) {
		cmd = CMD_ERASE;
		device = argv[1];
	} else if (((strcmp(argv[0], "fixtrx") == 0) && (argc == 2)) && mtd_fixtrx) {
		cmd = CMD_FIXTRX;
		device = argv[1];
	} else if (((strcmp(argv[0], "fixseama") == 0) && (argc == 2)) && mtd_fixseama) {
		cmd = CMD_FIXSEAMA;
		device = argv[1];
	} else if ((strcmp(argv[0], "verify") == 0) && (argc == 3)) {
		cmd = CMD_VERIFY;
		imagefile = argv[1];
		device = argv[2];
	} else if ((strcmp(argv[0], "dump") == 0) && (argc == 2)) {
		cmd = CMD_DUMP;
		device = argv[1];
	} else if ((strcmp(argv[0], "write") == 0) && (argc == 3)) {
		cmd = CMD_WRITE;
		device = argv[2];

		if (strcmp(argv[1], "-") == 0) {
			imagefile = "<stdin>";
			imagefd = 0;
		} else {
			imagefile = argv[1];
			if ((imagefd = open(argv[1], O_RDONLY)) < 0) {
				fprintf(stderr, "Couldn't open image file: %s!\n", imagefile);
				exit(1);
			}
		}

		if (!mtd_check(device)) {
			fprintf(stderr, "Can't open device for writing!\n");
			exit(1);
		}
		/* check trx file before erasing or writing anything */
		if (!image_check(imagefd, device) && !force) {
			fprintf(stderr, "Image check failed.\n");
			exit(1);
		}
	} else if ((strcmp(argv[0], "jffs2write") == 0) && (argc == 3)) {
		cmd = CMD_JFFS2WRITE;
		device = argv[2];

		imagefile = argv[1];
		if (!mtd_check(device)) {
			fprintf(stderr, "Can't open device for writing!\n");
			exit(1);
		}
	} else {
		usage();
	}

	sync();

	i = 0;
	unlocked = 0;
	while (erase[i] != NULL) {
		mtd_unlock(erase[i]);
		mtd_erase(erase[i]);
		if (strcmp(erase[i], device) == 0)
			unlocked = 1;
		i++;
	}

	switch (cmd) {
		case CMD_UNLOCK:
			if (!unlocked)
				mtd_unlock(device);
			break;
		case CMD_VERIFY:
			mtd_verify(device, imagefile);
			break;
		case CMD_DUMP:
			mtd_dump(device, offset, dump_len);
			break;
		case CMD_ERASE:
			if (!unlocked)
				mtd_unlock(device);
			mtd_erase(device);
			break;
		case CMD_WRITE:
			if (!unlocked)
				mtd_unlock(device);
			mtd_write(imagefd, device, fis_layout, part_offset);
			break;
		case CMD_JFFS2WRITE:
			if (!unlocked)
				mtd_unlock(device);
			mtd_write_jffs2(device, imagefile, jffs2dir);
			break;
		case CMD_FIXTRX:
		    if (mtd_fixtrx) {
			    mtd_fixtrx(device, offset);
            }
		case CMD_FIXSEAMA:
			if (mtd_fixseama)
			    mtd_fixseama(device, 0);
			break;
	}

	sync();

	if (boot)
		do_reboot();

	return 0;
}
예제 #10
0
파일: main.c 프로젝트: cooldroid/multirom
int main(int argc, const char *argv[])
{
    int i;
    const char *rom_to_boot = NULL;

    for(i = 1; i < argc; ++i)
    {
        if(strcmp(argv[i], "-v") == 0)
        {
            printf("%d%s apkL%d\n", VERSION_MULTIROM, VERSION_DEV_FIX, VERSION_APKL);
            fflush(stdout);
            return 0;
        }
        else if(strcmp(argv[i], "-apkL") == 0)
        {
            // Return all (internal and external) installed ROMs needed for the MultiROM Manager app

            // external partitions will be mounted to /mnt/mrom/APK and kept mounted so the app
            // can manipulate them, use "multirom -apkU" to unmount them when no longer needed

            // unmount everything in /mnt/mrom/APK first
            //multirom_apk_umount_usb();

            int i;
            struct multirom_status s;
            memset(&s, 0, sizeof(struct multirom_status));

            multirom_apk_get_roms(&s);

            for(i = 0; s.roms && s.roms[i]; ++i)
            {
                if (!s.roms[i]->partition)
                {
                    // Internal ROMs
                    printf("ROM: name=%s base=%s icon=%s\n",
                        s.roms[i]->name, s.roms[i]->base_path, s.roms[i]->icon_path);
                }
                else
                {
                    // External ROMs
                    printf("ROM: name=%s base=%s icon=%s part_name=%s part_mount=%s part_uuid=%s part_fs=%s\n",
                        s.roms[i]->name, s.roms[i]->base_path, s.roms[i]->icon_path,
                        s.roms[i]->partition->name, s.roms[i]->partition->mount_path, s.roms[i]->partition->uuid, s.roms[i]->partition->fs);
                }
            }
            fflush(stdout);

            multirom_free_status(&s);

            return 0;
        }
        else if(strcmp(argv[i], "-apkU") == 0)
        {
            // Unmount all partitions mounted in /mnt/mrom/APK
            multirom_apk_umount_usb();

            return 0;
        }
        else if(strncmp(argv[i], "--boot-rom=", sizeof("--boot-rom")) == 0)
        {
            rom_to_boot = argv[i] + sizeof("--boot-rom");
        }
    }

    srand(time(0));
    klog_init();

    // output all messages to dmesg,
    // but it is possible to filter out INFO messages
    klog_set_level(6);

    mrom_set_log_tag("multirom");

    ERROR("Running MultiROM v%d%s\n", VERSION_MULTIROM, VERSION_DEV_FIX);

    // root is mounted read only in android and MultiROM uses
    // it to store some temp files, so remount it.
    // Yes, there is better solution to this.
    if(rom_to_boot)
        mount(NULL, "/", NULL, MS_REMOUNT, NULL);

    int exit = multirom(rom_to_boot);

    if(rom_to_boot)
        mount(NULL, "/", NULL, MS_RDONLY | MS_REMOUNT, NULL);

    if(exit >= 0)
    {
        if(exit & EXIT_REBOOT_RECOVERY)
            do_reboot(REBOOT_RECOVERY);
        else if(exit & EXIT_REBOOT_BOOTLOADER)
            do_reboot(REBOOT_BOOTLOADER);
        else if(exit & EXIT_SHUTDOWN)
            do_reboot(REBOOT_SHUTDOWN);
        else if(exit & EXIT_REBOOT)
            do_reboot(REBOOT_SYSTEM);

        if(exit & EXIT_KEXEC)
        {
            do_kexec();
            return 0;
        }

        // indicates trampoline to keep /realdata mounted
        if(!(exit & EXIT_UMOUNT))
            close(open(KEEP_REALDATA, O_WRONLY | O_CREAT, 0000));
    }

    return 0;
}
예제 #11
0
/** Handle events that may need handling.
 * This routine is polled from bsd.c. At any call, it can handle
 * the HUP and USR1 signals. At calls that are 'on the second',
 * it goes on to perform regular every-second processing and to
 * check whether it's time to do other periodic processes like
 * purge, dump, or inactivity checks.
 */
void
dispatch(void)
{
  static int idle_counter = 0;
  struct module_entry_t *m;
  void (*handle)(void);

  /* A HUP reloads configuration and reopens logs */
  if (hup_triggered) {
    do_rawlog(LT_ERR, T("SIGHUP received: reloading .txt and .cnf files"));
    config_file_startup(NULL, 0);
    config_file_startup(NULL, 1);
    fcache_load(NOTHING);
    help_reindex(NOTHING);
    read_access_file();
    reopen_logs();
    hup_triggered = 0;
  }
  /* A USR1 does a shutdown/reboot */
  if (usr1_triggered) {
    do_reboot(NOTHING, 0);      /* We don't return from this */
    usr1_triggered = 0;         /* But just in case */
  }
  if (!globals.on_second)
    return;
  globals.on_second = 0;

  mudtime = time(NULL);

  do_second();

  migrate_stuff(CHUNK_MIGRATE_AMOUNT);

  if (options.purge_counter <= mudtime) {
    /* Free list reconstruction */
    options.purge_counter = options.purge_interval + mudtime;
    global_eval_context.cplr = NOTHING;
    strcpy(global_eval_context.ccom, "purge");
    purge();
    strcpy(global_eval_context.ccom, "");
  }

  if (options.dbck_counter <= mudtime) {
    /* Database consistency check */
    options.dbck_counter = options.dbck_interval + mudtime;
    global_eval_context.cplr = NOTHING;
    strcpy(global_eval_context.ccom, "dbck");
    dbck();
    strcpy(global_eval_context.ccom, "");
  }

  if (idle_counter <= mudtime) {
    /* Inactivity check */
    idle_counter = 30 + mudtime;
    inactivity_check();
  }

  /* Database dump routines */
  if (options.dump_counter <= mudtime) {
    log_mem_check();
    options.dump_counter = options.dump_interval + mudtime;
    global_eval_context.cplr = NOTHING;
    strcpy(global_eval_context.ccom, "dump");
    fork_and_dump(1);
    strcpy(global_eval_context.ccom, "");
    flag_broadcast(0, "ON-VACATION", "%s",
                   T
                   ("Your ON-VACATION flag is set! If you're back, clear it."));
  } else if (NO_FORK &&
             (options.dump_counter - 60 == mudtime) &&
             *options.dump_warning_1min) {
    flag_broadcast(0, 0, "%s", options.dump_warning_1min);
  } else if (NO_FORK &&
             (options.dump_counter - 300 == mudtime) &&
             *options.dump_warning_5min) {
    flag_broadcast(0, 0, "%s", options.dump_warning_5min);
  }
  if (options.warn_interval && (options.warn_counter <= mudtime)) {
    options.warn_counter = options.warn_interval + mudtime;
    global_eval_context.cplr = NOTHING;
    strcpy(global_eval_context.ccom, "warnings");
    run_topology();
    strcpy(global_eval_context.ccom, "");
  }
#ifdef MUSHCRON
  if((mudtime % 60) == 0)
    run_cron(); /* Run the MUSH Cron Daemon */
#endif /* MUSHCRON */
#ifdef _SWMP_
  sql_timer();
#endif
#ifdef RPMODE_SYS 
  rplog_reset();
#endif

  /* Replacement for local_timer */
  MODULE_ITER(m)
    MODULE_FUNC_NOARGS(handle, m->handle, "module_timer");
}
예제 #12
0
파일: main.c 프로젝트: skiwong20/multirom
int main(int argc, const char *argv[])
{
    int i;
    const char *rom_to_boot = NULL;

    for(i = 1; i < argc; ++i)
    {
        if(strcmp(argv[i], "-v") == 0)
        {
            printf("%d%s\n", VERSION_MULTIROM, VERSION_DEV_FIX);
            fflush(stdout);
            return 0;
        }
        else if(strncmp(argv[i], "--boot-rom=", sizeof("--boot-rom")) == 0)
        {
            rom_to_boot = argv[i] + sizeof("--boot-rom");
        }
    }

    srand(time(0));
    klog_init();

    // output all messages to dmesg,
    // but it is possible to filter out INFO messages
    klog_set_level(6);

    mrom_set_log_tag("multirom");

    ERROR("Running MultiROM v%d%s\n", VERSION_MULTIROM, VERSION_DEV_FIX);

    // root is mounted read only in android and MultiROM uses
    // it to store some temp files, so remount it.
    // Yes, there is better solution to this.
    if(rom_to_boot)
        mount(NULL, "/", NULL, MS_REMOUNT, NULL);

    int exit = multirom(rom_to_boot);

    if(rom_to_boot)
        mount(NULL, "/", NULL, MS_RDONLY | MS_REMOUNT, NULL);

    if(exit >= 0)
    {
        if(exit & EXIT_REBOOT_RECOVERY)
            do_reboot(REBOOT_RECOVERY);
        else if(exit & EXIT_REBOOT_BOOTLOADER)
            do_reboot(REBOOT_BOOTLOADER);
        else if(exit & EXIT_SHUTDOWN)
            do_reboot(REBOOT_SHUTDOWN);
        else if(exit & EXIT_REBOOT)
            do_reboot(REBOOT_SYSTEM);

        if(exit & EXIT_KEXEC)
        {
            do_kexec();
            return 0;
        }

        // indicates trampoline to keep /realdata mounted
        if(!(exit & EXIT_UMOUNT))
            close(open(KEEP_REALDATA, O_WRONLY | O_CREAT, 0000));
    }

    vt_set_mode(0);

    return 0;
}
예제 #13
0
파일: mtd.c 프로젝트: mirko/openwrt-x-burst
int main (int argc, char **argv)
{
	int ch, i, boot, imagefd = 0, force, unlocked;
	char *erase[MAX_ARGS], *device = NULL;
	enum {
		CMD_ERASE,
		CMD_WRITE,
		CMD_UNLOCK,
		CMD_REFRESH,
		CMD_JFFS2WRITE
	} cmd = -1;
	
	erase[0] = NULL;
	boot = 0;
	force = 0;
	buflen = 0;
	quiet = 0;

	while ((ch = getopt(argc, argv, "frqe:d:j:")) != -1)
		switch (ch) {
			case 'f':
				force = 1;
				break;
			case 'r':
				boot = 1;
				break;
			case 'j':
				jffs2file = optarg;
				break;
			case 'q':
				quiet++;
				break;
			case 'e':
				i = 0;
				while ((erase[i] != NULL) && ((i + 1) < MAX_ARGS))
					i++;
					
				erase[i++] = optarg;
				erase[i] = NULL;
				break;
			case 'd':
				jffs2dir = optarg;
				break;
			case '?':
			default:
				usage();
		}
	argc -= optind;
	argv += optind;
	
	if (argc < 2)
		usage();

	if ((strcmp(argv[0], "unlock") == 0) && (argc == 2)) {
		cmd = CMD_UNLOCK;
		device = argv[1];
	} else if ((strcmp(argv[0], "refresh") == 0) && (argc == 2)) {
		cmd = CMD_REFRESH;
		device = argv[1];
	} else if ((strcmp(argv[0], "erase") == 0) && (argc == 2)) {
		cmd = CMD_ERASE;
		device = argv[1];
	} else if ((strcmp(argv[0], "write") == 0) && (argc == 3)) {
		cmd = CMD_WRITE;
		device = argv[2];
	
		if (strcmp(argv[1], "-") == 0) {
			imagefile = "<stdin>";
			imagefd = 0;
		} else {
			imagefile = argv[1];
			if ((imagefd = open(argv[1], O_RDONLY)) < 0) {
				fprintf(stderr, "Couldn't open image file: %s!\n", imagefile);
				exit(1);
			}
		}
	
		if (!mtd_check(device)) {
			fprintf(stderr, "Can't open device for writing!\n");
			exit(1);
		}
		/* check trx file before erasing or writing anything */
		if (!image_check(imagefd, device) && !force) {
			fprintf(stderr, "Image check failed.\n");
			exit(1);
		}
	} else if ((strcmp(argv[0], "jffs2write") == 0) && (argc == 3)) {
		cmd = CMD_JFFS2WRITE;
		device = argv[2];
	
		imagefile = argv[1];
		if (!mtd_check(device)) {
			fprintf(stderr, "Can't open device for writing!\n");
			exit(1);
		}
	} else {
		usage();
	}

	sync();
	
	i = 0;
	unlocked = 0;
	while (erase[i] != NULL) {
		mtd_unlock(erase[i]);
		mtd_erase(erase[i]);
		if (strcmp(erase[i], device) == 0)
			unlocked = 1;
		i++;
	}
	
		
	switch (cmd) {
		case CMD_UNLOCK:
			if (!unlocked)
				mtd_unlock(device);
			break;
		case CMD_ERASE:
			if (!unlocked)
				mtd_unlock(device);
			mtd_erase(device);
			break;
		case CMD_WRITE:
			if (!unlocked)
				mtd_unlock(device);
			mtd_write(imagefd, device);
			break;
		case CMD_JFFS2WRITE:
			if (!unlocked)
				mtd_unlock(device);
			mtd_write_jffs2(device, imagefile, jffs2dir);
			break;
		case CMD_REFRESH:
			mtd_refresh(device);
			break;
	}

	sync();
	
	if (boot)
		do_reboot();

	return 0;
}
예제 #14
0
/*
** This function must a send reply from at least one node, otherwise
** the requesting fence_virtd will block forever in wait_cpt_reply.
*/
static void
do_real_work(void *data, size_t len, uint32_t nodeid, uint32_t seqno)
{
	struct cpg_info *info = cpg_virt_handle;
	struct cpg_fence_req *req = data;
	struct cpg_fence_req reply;
	int reply_code = -1;
	virt_state_t *vs = NULL;
	int cur_state;
	uint32_t cur_owner = 0;
	int local = 0;
	uint32_t my_id, high_id;

	dbg_printf(2, "Request %d for VM %s\n", req->request, req->vm_name);

	if (cpg_get_ids(&my_id, &high_id) == -1) {
		syslog(LOG_WARNING, "Unable to get CPG IDs");
		printf("Should never happen: Can't get CPG node ids - can't proceed\n");
		return;
	}

	memcpy(&reply, req, sizeof(reply));

	pthread_mutex_lock(&local_vm_list_lock);
	update_local_vms(info);
	if (strlen(req->vm_name)) {
		if (use_uuid)
			vs = vl_find_uuid(local_vm_list, req->vm_name);
		else
			vs = vl_find_name(local_vm_list, req->vm_name);

		if (vs) {
			local = 1;
			cur_owner = vs->v_state.s_owner;
			cur_state = vs->v_state.s_state;
			dbg_printf(2, "Found VM %s locally state %d\n",
				req->vm_name, cur_state);
		}
	}
	pthread_mutex_unlock(&local_vm_list_lock);

	if (vs == NULL) {
		pthread_mutex_lock(&remote_vm_list_lock);
		if (strlen(req->vm_name)) {
			if (use_uuid)
				vs = vl_find_uuid(remote_vm_list, req->vm_name);
			else
				vs = vl_find_name(remote_vm_list, req->vm_name);

			if (vs) {
				cur_owner = vs->v_state.s_owner;
				cur_state = vs->v_state.s_state;
				dbg_printf(2, "Found VM %s remotely on %u state %d\n",
					req->vm_name, cur_owner, cur_state);
			}
		}
		pthread_mutex_unlock(&remote_vm_list_lock);
	}

	if (!vs) {
		/*
		** We know about all domains on all nodes in the CPG group.
		** If we didn't find it, and we're high ID, act on the request.
		** We can safely assume the VM is OFF because it wasn't found
		** on any current members of the CPG group.
		*/
		if (my_id == high_id) {
			if (req->request == FENCE_STATUS)
				reply_code = RESP_OFF;
			else if (req->request == FENCE_OFF || req->request == FENCE_REBOOT)
				reply_code = RESP_SUCCESS;
			else
				reply_code = 1;

			dbg_printf(2, "Acting on request %d for unknown domain %s -> %d\n",
				req->request, req->vm_name, reply_code);
			goto out;
		}

		dbg_printf(2, "Not acting on request %d for unknown domain %s\n",
			req->request, req->vm_name);
		return;
	}

	if (local) {
		if (req->request == FENCE_STATUS) {
			/* We already have the status */
			if (cur_state == VIR_DOMAIN_SHUTOFF)
				reply_code = RESP_OFF;
			else
				reply_code = RESP_SUCCESS;
		} else if (req->request == FENCE_OFF) {
			reply_code = do_off(info, req->vm_name);
		} else if (req->request == FENCE_ON) {
			reply_code = do_on(info, req->vm_name);
		} else if (req->request == FENCE_REBOOT) {
			reply_code = do_reboot(info, req->vm_name);
		} else {
			dbg_printf(2, "Not explicitly handling request type %d for %s\n",
				req->request, req->vm_name);
			reply_code = 0;
		}
		goto out;
	}

	/*
	** This is a request for a non-local domain that exists on a
	** current CPG group member, so that member will see the request
	** and act on it. We don't need to do anything.
	*/
	dbg_printf(2, "Nothing to do for non-local domain %s seq %d owner %u\n",
		req->vm_name, seqno, cur_owner);
	return;

out:
	dbg_printf(2, "[%s] sending reply code seq %d -> %d\n",
		req->vm_name, seqno, reply_code);

	reply.response = reply_code;
	if (cpg_send_reply(&reply, sizeof(reply), nodeid, seqno) < 0) {
		dbg_printf(2, "cpg_send_reply failed for %s [%d %d]: %s\n",
			req->vm_name, nodeid, seqno, strerror(errno));
	}
}