Add support for -uuid and -domid args to QEMU

This commit is contained in:
Daniel P. Berrange 2008-11-04 22:15:30 +00:00
parent cbb1dd0a9b
commit 78439117bc
7 changed files with 68 additions and 4 deletions

View File

@ -1,3 +1,14 @@
Tue Nov 4 22:14:31 UTC 2008 Daniel P. Berrange <berrange@redhat.com>
Support passing UUID and ID to qemu/xenner
* src/qemu_conf.c, src/qemu_conf.h, src/qemu_driver.c: Detect
availability of -uuid and -domid args in QEMU, and use them if
available
* tests/qemuxml2argvtest.c,
tests/qemuxml2argvdata/qemuxml2argv-misc-uuid.args,
tests/qemuxml2argvdata/qemuxml2argv-misc-uuid.xml: Add test
case for -uuid and -domid args
Tue Nov 4 21:50:31 UTC 2008 Daniel P. Berrange <berrange@redhat.com>
Remove use of virStringList

View File

@ -439,6 +439,10 @@ int qemudExtractVersionInfo(const char *qemu,
flags |= QEMUD_CMD_FLAG_NO_REBOOT;
if (strstr(help, "-name"))
flags |= QEMUD_CMD_FLAG_NAME;
if (strstr(help, "-uuid"))
flags |= QEMUD_CMD_FLAG_UUID;
if (strstr(help, "-domid"))
flags |= QEMUD_CMD_FLAG_DOMID;
if (strstr(help, "-drive"))
flags |= QEMUD_CMD_FLAG_DRIVE;
if (strstr(help, "boot=on"))
@ -713,6 +717,8 @@ int qemudBuildCommandLine(virConnectPtr conn,
int qenvc = 0, qenva = 0;
const char **qenv = NULL;
const char *emulator;
char uuid[VIR_UUID_STRING_BUFLEN];
char domid[50];
uname(&ut);
@ -723,6 +729,8 @@ int qemudBuildCommandLine(virConnectPtr conn,
!ut.machine[4])
ut.machine[1] = '6';
virUUIDFormat(vm->def->uuid, uuid);
/* Need to explicitly disable KQEMU if
* 1. Arch matches host arch
* 2. Guest is 'qemu'
@ -802,6 +810,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
snprintf(memory, sizeof(memory), "%lu", vm->def->memory/1024);
snprintf(vcpus, sizeof(vcpus), "%lu", vm->def->vcpus);
snprintf(domid, sizeof(domid), "%d", vm->def->id);
ADD_ENV_LIT("LC_ALL=C");
@ -834,6 +843,15 @@ int qemudBuildCommandLine(virConnectPtr conn,
ADD_ARG_LIT("-name");
ADD_ARG_LIT(vm->def->name);
}
if (qemuCmdFlags & QEMUD_CMD_FLAG_UUID) {
ADD_ARG_LIT("-uuid");
ADD_ARG_LIT(uuid);
}
if (qemuCmdFlags & QEMUD_CMD_FLAG_DOMID) {
ADD_ARG_LIT("-domid");
ADD_ARG_LIT(domid);
}
/*
* NB, -nographic *MUST* come before any serial, or monitor
* or parallel port flags due to QEMU craziness, where it

View File

@ -44,6 +44,8 @@ enum qemud_cmd_flags {
QEMUD_CMD_FLAG_DRIVE = (1 << 3),
QEMUD_CMD_FLAG_DRIVE_BOOT = (1 << 4),
QEMUD_CMD_FLAG_NAME = (1 << 5),
QEMUD_CMD_FLAG_UUID = (1 << 6),
QEMUD_CMD_FLAG_DOMID = (1 << 7), /* Xenner only */
};
/* Main driver state */

View File

@ -860,10 +860,12 @@ static int qemudStartVMDaemon(virConnectPtr conn,
return -1;
}
vm->def->id = driver->nextvmid++;
if (qemudBuildCommandLine(conn, driver, vm,
qemuCmdFlags, &argv, &progenv,
&tapfds, &ntapfds, migrateFrom) < 0) {
close(vm->logfile);
vm->def->id = -1;
vm->logfile = -1;
return -1;
}
@ -901,10 +903,10 @@ static int qemudStartVMDaemon(virConnectPtr conn,
ret = virExec(conn, argv, progenv, &keepfd, &vm->pid,
vm->stdin_fd, &vm->stdout_fd, &vm->stderr_fd,
VIR_EXEC_NONBLOCK);
if (ret == 0) {
vm->def->id = driver->nextvmid++;
if (ret == 0)
vm->state = migrateFrom ? VIR_DOMAIN_PAUSED : VIR_DOMAIN_RUNNING;
}
else
vm->def->id = -1;
for (i = 0 ; argv[i] ; i++)
VIR_FREE(argv[i]);

View File

@ -0,0 +1 @@
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -name QEMUGuest1 -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 -domid 6 -nographic -monitor pty -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb

View File

@ -0,0 +1,25 @@
<domain type='qemu'>
<name>QEMUGuest1</name>
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory>219200</memory>
<currentMemory>219200</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu</emulator>
<disk type='block' device='disk'>
<source dev='/dev/HostVG/QEMUGuest1'/>
<target dev='hda' bus='ide'/>
</disk>
</devices>
</domain>

View File

@ -43,7 +43,10 @@ static int testCompareXMLToArgvFiles(const char *xml,
memset(&vm, 0, sizeof vm);
vm.def = vmdef;
vm.def->id = -1;
if (extraFlags & QEMUD_CMD_FLAG_DOMID)
vm.def->id = 6;
else
vm.def->id = -1;
vm.pid = -1;
flags = QEMUD_CMD_FLAG_VNC_COLON |
@ -196,6 +199,8 @@ mymain(int argc, char **argv)
DO_TEST("input-xen", 0);
DO_TEST("misc-acpi", 0);
DO_TEST("misc-no-reboot", 0);
DO_TEST("misc-uuid", QEMUD_CMD_FLAG_NAME |
QEMUD_CMD_FLAG_UUID | QEMUD_CMD_FLAG_DOMID);
DO_TEST("net-user", 0);
DO_TEST("net-virtio", 0);