return name;
}
+const char *
+virQEMUCapsGetDefaultMachine(virQEMUCapsPtr qemuCaps)
+{
+ size_t i;
+
+ for (i = 0; i < qemuCaps->nmachineTypes; i++) {
+ if (qemuCaps->machineTypes[i].qemuDefault)
+ return qemuCaps->machineTypes[i].name;
+ }
+
+ return NULL;
+}
int virQEMUCapsGetMachineMaxCpus(virQEMUCapsPtr qemuCaps,
const char *name)
virCPUMode mode);
const char *virQEMUCapsGetCanonicalMachine(virQEMUCapsPtr qemuCaps,
const char *name);
+const char *virQEMUCapsGetDefaultMachine(virQEMUCapsPtr qemuCaps);
int virQEMUCapsGetMachineMaxCpus(virQEMUCapsPtr qemuCaps,
const char *name);
bool virQEMUCapsGetMachineHotplugCpus(virQEMUCapsPtr qemuCaps,
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup;
- def = qemuParseCommandLineString(caps, driver->xmlopt, config,
+ def = qemuParseCommandLineString(driver->qemuCapsCache,
+ caps, driver->xmlopt, config,
NULL, NULL, NULL);
if (!def)
goto cleanup;
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup;
- if (!(def = qemuParseCommandLinePid(caps, driver->xmlopt, pid,
+ if (!(def = qemuParseCommandLinePid(driver->qemuCapsCache,
+ caps, driver->xmlopt, pid,
&pidfile, &monConfig, &monJSON)))
goto cleanup;
* as is practical. This is not an exact science....
*/
static virDomainDefPtr
-qemuParseCommandLine(virCapsPtr caps,
+qemuParseCommandLine(virFileCachePtr capsCache,
+ virCapsPtr caps,
virDomainXMLOptionPtr xmlopt,
char **progenv,
char **progargv,
virDomainDiskDefPtr disk = NULL;
const char *ceph_args = qemuFindEnv(progenv, "CEPH_ARGS");
bool have_sdl = false;
+ virQEMUCapsPtr qemuCaps;
if (pidfile)
*pidfile = NULL;
return NULL;
}
+ if (!(qemuCaps = virQEMUCapsCacheLookup(capsCache, progargv[0])))
+ goto error;
+
if (!(def = virDomainDefNew()))
goto error;
/* If no machine type has been found among the arguments, then figure
* out a reasonable value by using capabilities */
if (!def->os.machine) {
- virCapsDomainDataPtr capsdata;
+ const char *mach = virQEMUCapsGetDefaultMachine(qemuCaps);
- if (!(capsdata = virCapabilitiesDomainDataLookup(caps, def->os.type,
- def->os.arch, def->virtType, NULL, NULL)))
+ if (!mach) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Binary '%s' does not have a default machine type "
+ "and no '-machine' arg is present"),
+ progargv[0]);
goto error;
+ }
- if (VIR_STRDUP(def->os.machine, capsdata->machinetype) < 0) {
- VIR_FREE(capsdata);
+ if (VIR_STRDUP(def->os.machine, mach) < 0)
goto error;
- }
- VIR_FREE(capsdata);
}
/* Now the real processing loop */
else
qemuDomainCmdlineDefFree(cmd);
+ virObjectUnref(qemuCaps);
return def;
error:
}
if (pidfile)
VIR_FREE(*pidfile);
+ virObjectUnref(qemuCaps);
return NULL;
}
-virDomainDefPtr qemuParseCommandLineString(virCapsPtr caps,
+virDomainDefPtr qemuParseCommandLineString(virFileCachePtr capsCache,
+ virCapsPtr caps,
virDomainXMLOptionPtr xmlopt,
const char *args,
char **pidfile,
if (qemuStringToArgvEnv(args, &progenv, &progargv) < 0)
goto cleanup;
- def = qemuParseCommandLine(caps, xmlopt, progenv, progargv,
+ def = qemuParseCommandLine(capsCache, caps, xmlopt, progenv, progargv,
pidfile, monConfig, monJSON);
cleanup:
return ret;
}
-virDomainDefPtr qemuParseCommandLinePid(virCapsPtr caps,
+virDomainDefPtr qemuParseCommandLinePid(virFileCachePtr capsCache,
+ virCapsPtr caps,
virDomainXMLOptionPtr xmlopt,
pid_t pid,
char **pidfile,
qemuParseProcFileStrings(pid, "environ", &progenv) < 0)
goto cleanup;
- if (!(def = qemuParseCommandLine(caps, xmlopt, progenv, progargv,
+ if (!(def = qemuParseCommandLine(capsCache, caps, xmlopt, progenv, progargv,
pidfile, monConfig, monJSON)))
goto cleanup;
#ifndef __QEMU_PARSE_COMMAND_H__
# define __QEMU_PARSE_COMMAND_H__
+# include "virfilecache.h"
+
# define QEMU_QXL_VGAMEM_DEFAULT 16 * 1024
/*
* NB: def->name can be NULL upon return and the caller
* *must* decide how to fill in a name in this case
*/
-virDomainDefPtr qemuParseCommandLineString(virCapsPtr caps,
+virDomainDefPtr qemuParseCommandLineString(virFileCachePtr capsCache,
+ virCapsPtr caps,
virDomainXMLOptionPtr xmlopt,
const char *args,
char **pidfile,
virDomainChrSourceDefPtr *monConfig,
bool *monJSON);
-virDomainDefPtr qemuParseCommandLinePid(virCapsPtr caps,
+virDomainDefPtr qemuParseCommandLinePid(virFileCachePtr capsCache,
+ virCapsPtr caps,
virDomainXMLOptionPtr xmlopt,
pid_t pid,
char **pidfile,
+++ /dev/null
-LC_ALL=C \
-PATH=/bin \
-HOME=/home/test \
-USER=test \
-LOGNAME=test \
-QEMU_AUDIO_DRV=none \
-/usr/bin/qemu-system-aarch64 \
--name QEMUGuest1 \
--m 512 \
--hda /dev/HostVG/QEMUGuest1 \
--cdrom /root/boot.iso
+++ /dev/null
-<domain type='qemu'>
- <name>QEMUGuest1</name>
- <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
- <memory unit='KiB'>524288</memory>
- <currentMemory unit='KiB'>524288</currentMemory>
- <vcpu placement='static'>1</vcpu>
- <os>
- <type arch='aarch64' machine='virt'>hvm</type>
- <boot dev='hd'/>
- </os>
- <features>
- <gic version='2'/>
- </features>
- <clock offset='utc'/>
- <on_poweroff>destroy</on_poweroff>
- <on_reboot>restart</on_reboot>
- <on_crash>destroy</on_crash>
- <devices>
- <emulator>/usr/bin/qemu-system-aarch64</emulator>
- <disk type='block' device='disk'>
- <driver name='qemu' type='raw'/>
- <source dev='/dev/HostVG/QEMUGuest1'/>
- <target dev='hda' bus='ide'/>
- <address type='drive' controller='0' bus='0' target='0' unit='0'/>
- </disk>
- <disk type='file' device='cdrom'>
- <driver name='qemu' type='raw'/>
- <source file='/root/boot.iso'/>
- <target dev='hdc' bus='ide'/>
- <readonly/>
- <address type='drive' controller='0' bus='1' target='0' unit='0'/>
- </disk>
- <controller type='ide' index='0'/>
- <graphics type='sdl'/>
- <video>
- <model type='cirrus' vram='16384' heads='1' primary='yes'/>
- </video>
- <memballoon model='none'/>
- </devices>
-</domain>
<currentMemory unit='KiB'>524288</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
- <type arch='ppc64' machine='pseries'>hvm</type>
+ <type arch='ppc64' machine='pseries-2.12'>hvm</type>
<boot dev='hd'/>
</os>
<clock offset='utc'/>
<readonly/>
<address type='drive' controller='0' bus='0' target='0' unit='2'/>
</disk>
- <controller type='usb' index='0'>
+ <controller type='usb' index='0' model='pci-ohci'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
</controller>
<controller type='pci' index='0' model='pci-root'>
<currentMemory unit='KiB'>524288</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
- <type arch='x86_64' machine='pc-0.11'>hvm</type>
+ <type arch='x86_64' machine='pc-i440fx-2.12'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<readonly/>
<address type='drive' controller='0' bus='1' target='0' unit='0'/>
</disk>
- <controller type='usb' index='0'>
+ <controller type='usb' index='0' model='piix3-uhci'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<controller type='pci' index='0' model='pci-root'/>
<currentMemory unit='KiB'>524288</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
- <type arch='ppc64' machine='pseries'>hvm</type>
+ <type arch='ppc64' machine='pseries-2.12'>hvm</type>
<boot dev='hd'/>
</os>
<clock offset='utc'/>
<readonly/>
<address type='drive' controller='0' bus='0' target='0' unit='2'/>
</disk>
- <controller type='usb' index='0'>
+ <controller type='usb' index='0' model='pci-ohci'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
</controller>
<controller type='pci' index='0' model='pci-root'>
<currentMemory unit='KiB'>524288</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
- <type arch='ppc64' machine='pseries'>hvm</type>
+ <type arch='ppc64' machine='pseries-2.12'>hvm</type>
<boot dev='hd'/>
</os>
<clock offset='utc'/>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-ppc64</emulator>
- <controller type='usb' index='0'>
+ <controller type='usb' index='0' model='pci-ohci'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
</controller>
<controller type='pci' index='0' model='pci-root'>
if (virTestLoadFile(cmdfile, &cmd) < 0)
goto fail;
- if (!(vmdef = qemuParseCommandLineString(driver.caps, driver.xmlopt,
+ if (!(vmdef = qemuParseCommandLineString(driver.qemuCapsCache,
+ driver.caps, driver.xmlopt,
cmd, NULL, NULL, NULL)))
goto fail;
if (qemuTestDriverInit(&driver) < 0)
return EXIT_FAILURE;
+# define LOAD_CAPS(arch) \
+ do { \
+ virQEMUCapsPtr qemuCaps; \
+ qemuCaps = qemuTestParseCapabilitiesArch(VIR_ARCH_X86_64, \
+ "qemucapabilitiesdata/caps_2.12.0." arch ".xml"); \
+ if (virFileCacheInsertData(driver.qemuCapsCache, \
+ "/usr/bin/qemu-system-" arch, \
+ qemuCaps) < 0) \
+ return EXIT_FAILURE; \
+ } while (0)
+
+ LOAD_CAPS("x86_64");
+ LOAD_CAPS("aarch64");
+ LOAD_CAPS("ppc64");
# define DO_TEST_FULL(name, flags) \
do { \
DO_TEST("machine-keywrap-none-argv");
DO_TEST("nomachine-x86_64");
- DO_TEST("nomachine-aarch64");
DO_TEST("nomachine-ppc64");
qemuTestDriverFree(&driver);