mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00:00
qemu_command: assume QEMU_CAPS_DEVICE
Drop some checks that are no longer necessary as well as -usbdevice -pcidevice and -soundhw support.
This commit is contained in:
parent
33705aeec0
commit
34ab070c0d
@ -2890,9 +2890,6 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd,
|
||||
VIR_DOMAIN_CONTROLLER_TYPE_CCID,
|
||||
};
|
||||
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE))
|
||||
goto check_add_usb;
|
||||
|
||||
for (j = 0; j < ARRAY_CARDINALITY(contOrder); j++) {
|
||||
for (i = 0; i < def->ncontrollers; i++) {
|
||||
virDomainControllerDefPtr cont = def->controllers[i];
|
||||
@ -2961,7 +2958,6 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd,
|
||||
}
|
||||
}
|
||||
|
||||
check_add_usb:
|
||||
if (usbcontroller == 0 &&
|
||||
!qemuDomainMachineIsQ35(def) &&
|
||||
!ARCH_IS_S390(def->os.arch))
|
||||
@ -3664,25 +3660,12 @@ qemuBuildWatchdogCommandLine(virCommandPtr cmd,
|
||||
if (!def->watchdog)
|
||||
return 0;
|
||||
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||
virCommandAddArg(cmd, "-device");
|
||||
|
||||
optstr = qemuBuildWatchdogDevStr(def, watchdog, qemuCaps);
|
||||
if (!optstr)
|
||||
return -1;
|
||||
} else {
|
||||
virCommandAddArg(cmd, "-watchdog");
|
||||
|
||||
const char *model = virDomainWatchdogModelTypeToString(watchdog->model);
|
||||
if (!model) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("missing watchdog model"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (VIR_STRDUP(optstr, model) < 0)
|
||||
return -1;
|
||||
}
|
||||
virCommandAddArg(cmd, optstr);
|
||||
VIR_FREE(optstr);
|
||||
|
||||
@ -3945,27 +3928,12 @@ qemuBuildInputCommandLine(virCommandPtr cmd,
|
||||
virDomainInputDefPtr input = def->inputs[i];
|
||||
|
||||
if (input->bus == VIR_DOMAIN_INPUT_BUS_USB) {
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||
char *optstr;
|
||||
virCommandAddArg(cmd, "-device");
|
||||
if (!(optstr = qemuBuildUSBInputDevStr(def, input, qemuCaps)))
|
||||
return -1;
|
||||
virCommandAddArg(cmd, optstr);
|
||||
VIR_FREE(optstr);
|
||||
} else {
|
||||
switch (input->type) {
|
||||
case VIR_DOMAIN_INPUT_TYPE_MOUSE:
|
||||
virCommandAddArgList(cmd, "-usbdevice", "mouse", NULL);
|
||||
break;
|
||||
case VIR_DOMAIN_INPUT_TYPE_TABLET:
|
||||
virCommandAddArgList(cmd, "-usbdevice", "tablet", NULL);
|
||||
break;
|
||||
case VIR_DOMAIN_INPUT_TYPE_KBD:
|
||||
virCommandAddArgList(cmd, "-usbdevice", "keyboard",
|
||||
NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (input->bus == VIR_DOMAIN_INPUT_BUS_VIRTIO) {
|
||||
char *optstr;
|
||||
virCommandAddArg(cmd, "-device");
|
||||
@ -4094,10 +4062,6 @@ qemuBuildSoundCommandLine(virCommandPtr cmd,
|
||||
{
|
||||
size_t i, j;
|
||||
|
||||
if (!def->nsounds)
|
||||
return 0;
|
||||
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||
for (i = 0; i < def->nsounds; i++) {
|
||||
virDomainSoundDefPtr sound = def->sounds[i];
|
||||
char *str = NULL;
|
||||
@ -4147,39 +4111,6 @@ qemuBuildSoundCommandLine(virCommandPtr cmd,
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int size = 100;
|
||||
char *modstr;
|
||||
if (VIR_ALLOC_N(modstr, size+1) < 0)
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < def->nsounds && size > 0; i++) {
|
||||
virDomainSoundDefPtr sound = def->sounds[i];
|
||||
const char *model = virDomainSoundModelTypeToString(sound->model);
|
||||
if (!model) {
|
||||
VIR_FREE(modstr);
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("invalid sound model"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (sound->model == VIR_DOMAIN_SOUND_MODEL_ICH6 ||
|
||||
sound->model == VIR_DOMAIN_SOUND_MODEL_ICH9) {
|
||||
VIR_FREE(modstr);
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("this QEMU binary lacks hda support"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
strncat(modstr, model, size);
|
||||
size -= strlen(model);
|
||||
if (i < (def->nsounds - 1))
|
||||
strncat(modstr, ",", size--);
|
||||
}
|
||||
virCommandAddArgList(cmd, "-soundhw", modstr, NULL);
|
||||
VIR_FREE(modstr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -4369,8 +4300,7 @@ qemuBuildVideoCommandLine(virCommandPtr cmd,
|
||||
const char *dev = qemuDeviceVideoTypeToString(primaryVideoType);
|
||||
|
||||
if (def->videos[0]->type == VIR_DOMAIN_VIDEO_TYPE_QXL &&
|
||||
(def->videos[0]->vram || def->videos[0]->ram) &&
|
||||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||
(def->videos[0]->vram || def->videos[0]->ram)) {
|
||||
unsigned int ram = def->videos[0]->ram;
|
||||
unsigned int vram = def->videos[0]->vram;
|
||||
unsigned int vram64 = def->videos[0]->vram64;
|
||||
@ -4413,8 +4343,7 @@ qemuBuildVideoCommandLine(virCommandPtr cmd,
|
||||
}
|
||||
}
|
||||
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) &&
|
||||
def->videos[0]->vram &&
|
||||
if (def->videos[0]->vram &&
|
||||
((primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VGA &&
|
||||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_VGAMEM)) ||
|
||||
(primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VMVGA &&
|
||||
@ -4434,8 +4363,6 @@ qemuBuildVideoCommandLine(virCommandPtr cmd,
|
||||
}
|
||||
}
|
||||
|
||||
if (def->nvideos > 1) {
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||
for (i = 1; i < def->nvideos; i++) {
|
||||
char *str;
|
||||
if (def->videos[i]->type != VIR_DOMAIN_VIDEO_TYPE_QXL) {
|
||||
@ -4454,12 +4381,6 @@ qemuBuildVideoCommandLine(virCommandPtr cmd,
|
||||
virCommandAddArg(cmd, str);
|
||||
VIR_FREE(str);
|
||||
}
|
||||
} else {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("only one video card is currently supported"));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -4555,34 +4476,6 @@ qemuBuildPCIHostdevDevStr(const virDomainDef *def,
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
qemuBuildPCIHostdevPCIDevStr(virDomainHostdevDefPtr dev,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
char *ret = NULL;
|
||||
virDomainHostdevSubsysPCIPtr pcisrc = &dev->source.subsys.u.pci;
|
||||
|
||||
if (pcisrc->addr.domain) {
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_HOST_PCI_MULTIDOMAIN)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("non-zero domain='%.4x' in host device PCI address "
|
||||
"not supported in this QEMU binary"),
|
||||
pcisrc->addr.domain);
|
||||
goto cleanup;
|
||||
}
|
||||
ignore_value(virAsprintf(&ret, "host=%.4x:%.2x:%.2x.%.1x",
|
||||
pcisrc->addr.domain, pcisrc->addr.bus,
|
||||
pcisrc->addr.slot, pcisrc->addr.function));
|
||||
} else {
|
||||
ignore_value(virAsprintf(&ret, "host=%.2x:%.2x.%.1x",
|
||||
pcisrc->addr.bus, pcisrc->addr.slot,
|
||||
pcisrc->addr.function));
|
||||
}
|
||||
cleanup:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
qemuBuildUSBHostdevDevStr(const virDomainDef *def,
|
||||
virDomainHostdevDefPtr dev,
|
||||
@ -4678,28 +4571,6 @@ qemuBuildHubCommandLine(virCommandPtr cmd,
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
qemuBuildUSBHostdevUSBDevStr(virDomainHostdevDefPtr dev)
|
||||
{
|
||||
char *ret = NULL;
|
||||
virDomainHostdevSubsysUSBPtr usbsrc = &dev->source.subsys.u.usb;
|
||||
|
||||
if (dev->missing) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("This QEMU doesn't not support missing USB devices"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!usbsrc->bus && !usbsrc->device) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("USB host device is missing bus/device information"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ignore_value(virAsprintf(&ret, "host:%d.%d", usbsrc->bus, usbsrc->device));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char *
|
||||
qemuBuildSCSIHostHostdevDrvStr(virDomainHostdevDefPtr dev)
|
||||
{
|
||||
@ -5105,20 +4976,12 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
|
||||
if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
|
||||
subsys->type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) {
|
||||
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||
virCommandAddArg(cmd, "-device");
|
||||
if (!(devstr =
|
||||
qemuBuildUSBHostdevDevStr(def, hostdev, qemuCaps)))
|
||||
return -1;
|
||||
virCommandAddArg(cmd, devstr);
|
||||
VIR_FREE(devstr);
|
||||
} else {
|
||||
virCommandAddArg(cmd, "-usbdevice");
|
||||
if (!(devstr = qemuBuildUSBHostdevUSBDevStr(hostdev)))
|
||||
return -1;
|
||||
virCommandAddArg(cmd, devstr);
|
||||
VIR_FREE(devstr);
|
||||
}
|
||||
}
|
||||
|
||||
/* PCI */
|
||||
@ -5135,7 +4998,6 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
|
||||
}
|
||||
}
|
||||
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||
char *configfd_name = NULL;
|
||||
unsigned int bootIndex = hostdev->info->bootIndex;
|
||||
|
||||
@ -5169,24 +5031,12 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
|
||||
return -1;
|
||||
virCommandAddArg(cmd, devstr);
|
||||
VIR_FREE(devstr);
|
||||
} else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCIDEVICE)) {
|
||||
virCommandAddArg(cmd, "-pcidevice");
|
||||
if (!(devstr = qemuBuildPCIHostdevPCIDevStr(hostdev, qemuCaps)))
|
||||
return -1;
|
||||
virCommandAddArg(cmd, devstr);
|
||||
VIR_FREE(devstr);
|
||||
} else {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("PCI device assignment is not supported by this version of qemu"));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* SCSI */
|
||||
if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
|
||||
subsys->type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) {
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) &&
|
||||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SCSI_GENERIC)) {
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SCSI_GENERIC)) {
|
||||
char *drvstr;
|
||||
|
||||
virCommandAddArg(cmd, "-drive");
|
||||
@ -5880,11 +5730,6 @@ qemuBuildSgaCommandLine(virCommandPtr cmd,
|
||||
{
|
||||
/* Serial graphics adapter */
|
||||
if (def->os.bios.useserial == VIR_TRISTATE_BOOL_YES) {
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("qemu does not support -device"));
|
||||
return -1;
|
||||
}
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SGA)) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("qemu does not support SGA"));
|
||||
@ -8605,8 +8450,7 @@ qemuBuildParallelsCommandLine(virLogManagerPtr logManager,
|
||||
char *devstr;
|
||||
|
||||
/* Use -chardev with -device if they are available */
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV) &&
|
||||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV)) {
|
||||
if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, def,
|
||||
¶llel->source,
|
||||
parallel->info.alias,
|
||||
@ -8647,8 +8491,7 @@ qemuBuildChannelsCommandLine(virLogManagerPtr logManager,
|
||||
|
||||
switch (channel->targetType) {
|
||||
case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD:
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV) ||
|
||||
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
"%s", _("guestfwd requires QEMU to support -chardev & -device"));
|
||||
return -1;
|
||||
@ -8670,12 +8513,6 @@ qemuBuildChannelsCommandLine(virLogManagerPtr logManager,
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO:
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("virtio channel requires QEMU to support -device"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: Refactor so that we generate this (and onther
|
||||
* things) somewhere else then where we are building the
|
||||
@ -8735,11 +8572,6 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager,
|
||||
switch (console->targetType) {
|
||||
case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLP:
|
||||
case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM:
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("sclp console requires QEMU to support -device"));
|
||||
return -1;
|
||||
}
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCLP_S390)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("sclp console requires QEMU to support s390-sclp"));
|
||||
@ -8760,12 +8592,6 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager,
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO:
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("virtio channel requires QEMU to support -device"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, def,
|
||||
&console->source,
|
||||
console->info.alias,
|
||||
@ -8905,12 +8731,6 @@ qemuBuildRedirdevCommandLine(virLogManagerPtr logManager,
|
||||
virCommandAddArg(cmd, devstr);
|
||||
VIR_FREE(devstr);
|
||||
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("redirected devices are not supported by this QEMU"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
virCommandAddArg(cmd, "-device");
|
||||
if (!(devstr = qemuBuildRedirdevDevStr(def, redirdev, qemuCaps)))
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user