diff --git a/ChangeLog b/ChangeLog index 052f05659d764a2a5b24501411a0bc464e0dfcb1..10c660120f0caf6097d3d0f62c2e49e657d716de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,20 @@ -Thu Sep 5 12:33:26 BST 2008 Daniel P. Berrange +Fri Sep 5 12:50:26 BST 2008 Daniel P. Berrange + + Fix starting of Xen domains without PVFB console, by not + setting emulator path in SEXPR unless asked for + * src/domain_conf.c, src/domain_conf.h, src/xm_internal.c: Don't + set emulator path with a default value + * src/lxc_driver.c, src/qemu_conf.c, src/qemu_driver.c: Find a + default emulator path if no explicit path is provided in config + * tests/xmconfigdata/test-paravirt-net-e1000.xml, + tests/xmconfigdata/test-paravirt-new-pvfb.xml, + tests/xmconfigdata/test-paravirt-old-pvfb.xml, + tests/xml2sexprdata/xml2sexpr-fv-kernel.xml: Remove default + emulator path + * tests/xml2sexprdata/xml2sexpr-pv-vfb-new.sexpr: Remove + emulator path + +Fri Sep 5 12:33:26 BST 2008 Daniel P. Berrange * src/xen_unified.c, src/xen_internal.c, src/xen_internal.h, tests/xencapstest.c: Pass connection object into capabilities diff --git a/src/domain_conf.c b/src/domain_conf.c index 42f914f2e4610607f567888e6c458952b14f46db..6a35064f804f7782c11d1b057ac791d0a98851d0 100644 --- a/src/domain_conf.c +++ b/src/domain_conf.c @@ -1917,24 +1917,6 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, } def->emulator = virXPathString(conn, "string(./devices/emulator[1])", ctxt); - if (!def->emulator) { - const char *type = virDomainVirtTypeToString(def->virtType); - if (!type) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, - "%s", _("unknown virt type")); - goto error; - } - const char *emulator = virCapabilitiesDefaultGuestEmulator(caps, - def->os.type, - def->os.arch, - type); - - if (emulator && - !(def->emulator = strdup(emulator))) { - virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL); - goto error; - } - } /* analysis of the disk devices */ if ((n = virXPathNodeSet(conn, "./devices/disk", ctxt, &nodes)) < 0) { @@ -3449,4 +3431,33 @@ int virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk, return 0; } +const char *virDomainDefDefaultEmulator(virConnectPtr conn, + virDomainDefPtr def, + virCapsPtr caps) { + const char *type; + const char *emulator; + + type = virDomainVirtTypeToString(def->virtType); + if (!type) { + virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + "%s", _("unknown virt type")); + return NULL; + } + + emulator = virCapabilitiesDefaultGuestEmulator(caps, + def->os.type, + def->os.arch, + type); + + if (!emulator) { + virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + _("no emulator for domain %s os type %s on architecture %s"), + type, def->os.type, def->os.arch); + return NULL; + } + + return emulator; +} + + #endif /* ! PROXY */ diff --git a/src/domain_conf.h b/src/domain_conf.h index de8a043615c663d30629323487ecc4f9cf7cf7dc..632e5adf4e00dffd2017827cfc68dace030da0dc 100644 --- a/src/domain_conf.h +++ b/src/domain_conf.h @@ -562,6 +562,11 @@ int virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk, virDomainNetDefPtr virDomainNetDefParseXML(virConnectPtr conn, xmlNodePtr node); +const char *virDomainDefDefaultEmulator(virConnectPtr conn, + virDomainDefPtr def, + virCapsPtr caps); + + VIR_ENUM_DECL(virDomainVirt) VIR_ENUM_DECL(virDomainBoot) VIR_ENUM_DECL(virDomainFeature) diff --git a/src/lxc_driver.c b/src/lxc_driver.c index fd1eff436bc2210ad5db83f8f8a5082dd9edaf7e..9dfe418436daa2d914e2f8decd5a03925b851aef 100644 --- a/src/lxc_driver.c +++ b/src/lxc_driver.c @@ -623,6 +623,8 @@ static int lxcControllerStart(virConnectPtr conn, int status; fd_set keepfd; char appPtyStr[30]; + const char *emulator; + lxc_driver_t *driver = conn->privateData; FD_ZERO(&keepfd); @@ -650,7 +652,13 @@ static int lxcControllerStart(virConnectPtr conn, snprintf(appPtyStr, sizeof(appPtyStr), "%d", appPty); - ADD_ARG_LIT(vm->def->emulator); + emulator = vm->def->emulator; + if (!emulator) + emulator = virDomainDefDefaultEmulator(conn, vm->def, driver->caps); + if (!emulator) + return -1; + + ADD_ARG_LIT(emulator); ADD_ARG_LIT("--name"); ADD_ARG_LIT(vm->def->name); ADD_ARG_LIT("--console"); diff --git a/src/qemu_conf.c b/src/qemu_conf.c index 22a99ecb04c2a3eaca340c191eefcd8d23529e55..d742c320fc63459527ef85f91d45d4ef505cf456 100644 --- a/src/qemu_conf.c +++ b/src/qemu_conf.c @@ -728,6 +728,7 @@ int qemudBuildCommandLine(virConnectPtr conn, int disableKQEMU = 0; int qargc = 0, qarga = 0; const char **qargv = NULL; + const char *emulator; uname(&ut); @@ -783,6 +784,11 @@ int qemudBuildCommandLine(virConnectPtr conn, snprintf(memory, sizeof(memory), "%lu", vm->def->memory/1024); snprintf(vcpus, sizeof(vcpus), "%lu", vm->def->vcpus); + emulator = vm->def->emulator; + if (!emulator) + emulator = virDomainDefDefaultEmulator(conn, vm->def, driver->caps); + if (!emulator) + return -1; ADD_ARG_LIT(vm->def->emulator); ADD_ARG_LIT("-S"); diff --git a/src/qemu_driver.c b/src/qemu_driver.c index 167876dbacc7e908117043c01528a06fda0e2742..8f8fb613e590b045184b0d8d4c47e237f07d5a81 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -850,6 +850,7 @@ static int qemudStartVMDaemon(virConnectPtr conn, int ntapfds = 0; unsigned int qemuCmdFlags; fd_set keepfd; + const char *emulator; FD_ZERO(&keepfd); @@ -909,24 +910,30 @@ static int qemudStartVMDaemon(virConnectPtr conn, return -1; } + emulator = vm->def->emulator; + if (!emulator) + emulator = virDomainDefDefaultEmulator(conn, vm->def, driver->caps); + if (!emulator) + return -1; + /* Make sure the binary we are about to try exec'ing exists. * Technically we could catch the exec() failure, but that's * in a sub-process so its hard to feed back a useful error */ - if (stat(vm->def->emulator, &sb) < 0) { + if (stat(emulator, &sb) < 0) { qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, _("Cannot find QEMU binary %s: %s"), - vm->def->emulator, + emulator, strerror(errno)); return -1; } - if (qemudExtractVersionInfo(vm->def->emulator, + if (qemudExtractVersionInfo(emulator, NULL, &qemuCmdFlags) < 0) { qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, _("Cannot determine QEMU argv syntax %s"), - vm->def->emulator); + emulator); return -1; } diff --git a/src/xm_internal.c b/src/xm_internal.c index d478274d3500b61988cf4a16f5a850158f3c6e50..ad7f8929321634ba3a6016fb02a1e45597054303 100644 --- a/src/xm_internal.c +++ b/src/xm_internal.c @@ -785,26 +785,6 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) { if (xenXMConfigCopyStringOpt(conn, conf, "device_model", &def->emulator) < 0) goto cleanup; - if (def->emulator == NULL) { - const char *type = virDomainVirtTypeToString(def->virtType); - if (!type) { - xenXMError(conn, VIR_ERR_INTERNAL_ERROR, - "%s", _("unknown virt type")); - goto cleanup; - } - const char *emulator = virCapabilitiesDefaultGuestEmulator(priv->caps, - def->os.type, - def->os.arch, - type); - if (!emulator) { - xenXMError(conn, VIR_ERR_INTERNAL_ERROR, - "%s", _("unsupported guest type")); - goto cleanup; - } - if (!(def->emulator = strdup(emulator))) - goto no_memory; - } - list = virConfGetValue(conf, "disk"); if (list && list->type == VIR_CONF_LIST) { list = list->list; diff --git a/tests/xmconfigdata/test-paravirt-net-e1000.xml b/tests/xmconfigdata/test-paravirt-net-e1000.xml index 8efab5871e903f389065e25aa1b69d95cd5a283a..c423af12acd9042dc9ccc22c0d7f878efe8bdf70 100644 --- a/tests/xmconfigdata/test-paravirt-net-e1000.xml +++ b/tests/xmconfigdata/test-paravirt-net-e1000.xml @@ -13,7 +13,6 @@ restart restart - /usr/lib/xen/bin/qemu-dm diff --git a/tests/xmconfigdata/test-paravirt-new-pvfb.xml b/tests/xmconfigdata/test-paravirt-new-pvfb.xml index 620f701e0ab385000c9d96dcb6382368580776e0..de1a9aecaeeb4bae8d2634fab1d9e184d22f809a 100644 --- a/tests/xmconfigdata/test-paravirt-new-pvfb.xml +++ b/tests/xmconfigdata/test-paravirt-new-pvfb.xml @@ -13,7 +13,6 @@ restart restart - /usr/lib/xen/bin/qemu-dm diff --git a/tests/xmconfigdata/test-paravirt-old-pvfb.xml b/tests/xmconfigdata/test-paravirt-old-pvfb.xml index 620f701e0ab385000c9d96dcb6382368580776e0..de1a9aecaeeb4bae8d2634fab1d9e184d22f809a 100644 --- a/tests/xmconfigdata/test-paravirt-old-pvfb.xml +++ b/tests/xmconfigdata/test-paravirt-old-pvfb.xml @@ -13,7 +13,6 @@ restart restart - /usr/lib/xen/bin/qemu-dm diff --git a/tests/xml2sexprdata/xml2sexpr-fv-kernel.xml b/tests/xml2sexprdata/xml2sexpr-fv-kernel.xml index d33218c50e2a44c44c70e7309068307873f1f9fc..6c76669e5453279f53f9c2f0fc3be4ffd94dfce7 100644 --- a/tests/xml2sexprdata/xml2sexpr-fv-kernel.xml +++ b/tests/xml2sexprdata/xml2sexpr-fv-kernel.xml @@ -14,6 +14,7 @@ destroy destroy + /usr/lib/xen/bin/qemu-dm diff --git a/tests/xml2sexprdata/xml2sexpr-pv-vfb-new.sexpr b/tests/xml2sexprdata/xml2sexpr-pv-vfb-new.sexpr index 7a04acbb199134cdb2311658a06de9657afc77d2..7d4de13a95c34576615a07199def21be88763ccd 100644 --- a/tests/xml2sexprdata/xml2sexpr-pv-vfb-new.sexpr +++ b/tests/xml2sexprdata/xml2sexpr-pv-vfb-new.sexpr @@ -1 +1 @@ -(vm (name 'pvtest')(memory 420)(maxmem 420)(vcpus 2)(uuid '596a5d21-71f4-8fb2-e068-e2386a5c413e')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(image (linux (kernel '/var/lib/xen/vmlinuz.2Dn2YT')(ramdisk '/var/lib/xen/initrd.img.0u-Vhq')(args ' method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test/5.91/x86_64/os ')(device_model '/usr/lib/xen/bin/qemu-dm')))(device (vbd (dev 'xvda')(uname 'file:/root/some.img')(mode 'w')))(device (vkbd))(device (vfb (type vnc)(vncunused 0)(vncdisplay 6)(vnclisten '127.0.0.1')(vncpasswd '123456')(keymap 'ja')))) \ No newline at end of file +(vm (name 'pvtest')(memory 420)(maxmem 420)(vcpus 2)(uuid '596a5d21-71f4-8fb2-e068-e2386a5c413e')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(image (linux (kernel '/var/lib/xen/vmlinuz.2Dn2YT')(ramdisk '/var/lib/xen/initrd.img.0u-Vhq')(args ' method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test/5.91/x86_64/os ')))(device (vbd (dev 'xvda')(uname 'file:/root/some.img')(mode 'w')))(device (vkbd))(device (vfb (type vnc)(vncunused 0)(vncdisplay 6)(vnclisten '127.0.0.1')(vncpasswd '123456')(keymap 'ja')))) \ No newline at end of file