From 126d3ebeeaa78fb2da31d6534756d45ee7d45bf1 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Fri, 5 Sep 2008 11:52:12 +0000 Subject: [PATCH] Fix starting of xen domains without a PVFB console by removing default emulator --- ChangeLog | 18 ++++++- src/domain_conf.c | 47 ++++++++++++------- src/domain_conf.h | 5 ++ src/lxc_driver.c | 10 +++- src/qemu_conf.c | 6 +++ src/qemu_driver.c | 15 ++++-- src/xm_internal.c | 20 -------- .../xmconfigdata/test-paravirt-net-e1000.xml | 1 - tests/xmconfigdata/test-paravirt-new-pvfb.xml | 1 - tests/xmconfigdata/test-paravirt-old-pvfb.xml | 1 - tests/xml2sexprdata/xml2sexpr-fv-kernel.xml | 1 + .../xml2sexprdata/xml2sexpr-pv-vfb-new.sexpr | 2 +- 12 files changed, 79 insertions(+), 48 deletions(-) diff --git a/ChangeLog b/ChangeLog index 052f05659d..10c660120f 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 42f914f2e4..6a35064f80 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 de8a043615..632e5adf4e 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 fd1eff436b..9dfe418436 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 22a99ecb04..d742c320fc 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 167876dbac..8f8fb613e5 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 d478274d35..ad7f892932 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 8efab5871e..c423af12ac 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 620f701e0a..de1a9aecae 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 620f701e0a..de1a9aecae 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 d33218c50e..6c76669e54 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 7a04acbb19..7d4de13a95 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 -- GitLab