提交 126d3ebe 编写于 作者: D Daniel P. Berrange

Fix starting of xen domains without a PVFB console by removing default emulator

上级 f193e195
Thu Sep 5 12:33:26 BST 2008 Daniel P. Berrange <berrange@redhat.com>
Fri Sep 5 12:50:26 BST 2008 Daniel P. Berrange <berrange@redhat.com>
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 <berrange@redhat.com>
* src/xen_unified.c, src/xen_internal.c, src/xen_internal.h,
tests/xencapstest.c: Pass connection object into capabilities
......
......@@ -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 */
......@@ -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)
......
......@@ -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");
......
......@@ -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");
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -13,7 +13,6 @@
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/lib/xen/bin/qemu-dm</emulator>
<disk type='block' device='disk'>
<driver name='phy'/>
<source dev='/dev/HostVG/XenGuest1'/>
......
......@@ -13,7 +13,6 @@
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/lib/xen/bin/qemu-dm</emulator>
<disk type='block' device='disk'>
<driver name='phy'/>
<source dev='/dev/HostVG/XenGuest1'/>
......
......@@ -13,7 +13,6 @@
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/lib/xen/bin/qemu-dm</emulator>
<disk type='block' device='disk'>
<driver name='phy'/>
<source dev='/dev/HostVG/XenGuest1'/>
......
......@@ -14,6 +14,7 @@
<on_reboot>destroy</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/lib/xen/bin/qemu-dm</emulator>
<disk type='file' device='disk'>
<source file='/root/some.img'/>
<target dev='xvda'/>
......
(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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册