diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a5ff7695c3..f67176fbfd 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1608,6 +1608,7 @@ qemuBuildDiskDeviceProps(const virDomainDef *def, g_autofree char *chardev = NULL; g_autofree char *drive = NULL; unsigned int bootindex = 0; + const char *bootLoadparm = NULL; unsigned int logical_block_size = disk->blockio.logical_block_size; unsigned int physical_block_size = disk->blockio.physical_block_size; unsigned int discard_granularity = disk->blockio.discard_granularity; @@ -1746,9 +1747,13 @@ qemuBuildDiskDeviceProps(const virDomainDef *def, } /* bootindex for floppies is configured via the fdc controller */ - if (disk->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY) + if (disk->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY) { bootindex = disk->info.effectiveBootIndex; + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW_DEVICE_LOADPARM)) + bootLoadparm = disk->info.loadparm; + } + if (disk->wwn) { unsigned long long w = 0; @@ -1791,6 +1796,7 @@ qemuBuildDiskDeviceProps(const virDomainDef *def, "S:chardev", chardev, "s:id", disk->info.alias, "p:bootindex", bootindex, + "S:loadparm", bootLoadparm, "p:logical_block_size", logical_block_size, "p:physical_block_size", physical_block_size, "p:discard_granularity", discard_granularity, @@ -3616,6 +3622,7 @@ qemuBuildNicDevProps(virDomainDef *def, g_autoptr(virJSONValue) props = NULL; char macaddr[VIR_MAC_STRING_BUFLEN]; g_autofree char *netdev = g_strdup_printf("host%s", net->info.alias); + const char *bootLoadparm = NULL; if (virDomainNetIsVirtioModel(net)) { const char *tx = NULL; @@ -3701,11 +3708,15 @@ qemuBuildNicDevProps(virDomainDef *def, virMacAddrFormat(&net->mac, macaddr); + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW_DEVICE_LOADPARM)) + bootLoadparm = net->info.loadparm; + if (virJSONValueObjectAdd(&props, "s:netdev", netdev, "s:id", net->info.alias, "s:mac", macaddr, "p:bootindex", net->info.effectiveBootIndex, + "S:loadparm", bootLoadparm, NULL) < 0) return NULL; @@ -4751,15 +4762,21 @@ qemuBuildSCSIVHostHostdevDevProps(const virDomainDef *def, virJSONValue * qemuBuildSCSIHostdevDevProps(const virDomainDef *def, virDomainHostdevDef *dev, - const char *backendAlias) + const char *backendAlias, + virQEMUCaps *qemuCaps) { + const char *bootLoadparm = NULL; g_autoptr(virJSONValue) props = NULL; + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW_DEVICE_LOADPARM)) + bootLoadparm = dev->info->loadparm; + if (virJSONValueObjectAdd(&props, "s:driver", "scsi-generic", "s:drive", backendAlias, "s:id", dev->info->alias, "p:bootindex", dev->info->bootIndex, + "S:loadparm", bootLoadparm, NULL) < 0) return NULL; @@ -4840,16 +4857,21 @@ qemuBuildHostdevMdevModelTypeString(virDomainHostdevSubsysMediatedDev *mdev) virJSONValue * qemuBuildHostdevMediatedDevProps(const virDomainDef *def, - virDomainHostdevDef *dev) + virDomainHostdevDef *dev, + virQEMUCaps *qemuCaps) { g_autoptr(virJSONValue) props = NULL; virDomainHostdevSubsysMediatedDev *mdevsrc = &dev->source.subsys.u.mdev; g_autofree char *mdevPath = NULL; + const char *bootLoadparm = NULL; /* 'ramfb' property must be omitted unless it's to be enabled */ bool ramfb = mdevsrc->ramfb == VIR_TRISTATE_SWITCH_ON; mdevPath = virMediatedDeviceGetSysfsPath(mdevsrc->uuidstr); + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW_DEVICE_LOADPARM)) + bootLoadparm = dev->info->loadparm; + if (virJSONValueObjectAdd(&props, "s:driver", qemuBuildHostdevMdevModelTypeString(mdevsrc), "s:id", dev->info->alias, @@ -4857,6 +4879,7 @@ qemuBuildHostdevMediatedDevProps(const virDomainDef *def, "S:display", qemuOnOffAuto(mdevsrc->display), "B:ramfb", ramfb, "p:bootindex", dev->info->bootIndex, + "S:loadparm", bootLoadparm, NULL) < 0) return NULL; @@ -4955,7 +4978,7 @@ qemuBuildHostdevSCSICommandLine(virCommand *cmd, if (qemuBuildBlockStorageSourceAttachDataCommandline(cmd, data, qemuCaps) < 0) return -1; - if (!(devprops = qemuBuildSCSIHostdevDevProps(def, hostdev, backendAlias))) + if (!(devprops = qemuBuildSCSIHostdevDevProps(def, hostdev, backendAlias, qemuCaps))) return -1; if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, def, qemuCaps) < 0) @@ -5054,7 +5077,7 @@ qemuBuildHostdevCommandLine(virCommand *cmd, return -1; } - if (!(devprops = qemuBuildHostdevMediatedDevProps(def, hostdev))) + if (!(devprops = qemuBuildHostdevMediatedDevProps(def, hostdev, qemuCaps))) return -1; if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, def, qemuCaps) < 0) @@ -6879,7 +6902,8 @@ qemuBuildMachineCommandLine(virCommand *cmd, virBufferAsprintf(&buf, ",max-cpu-compat=%s", cpu->model); } - qemuAppendLoadparmMachineParm(&buf, def); + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW_DEVICE_LOADPARM)) + qemuAppendLoadparmMachineParm(&buf, def); if (def->sec) { switch (def->sec->sectype) { diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 309e566f6c..befc3f4ef9 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -179,7 +179,8 @@ qemuBuildUSBHostdevDevProps(const virDomainDef *def, virJSONValue * qemuBuildSCSIHostdevDevProps(const virDomainDef *def, virDomainHostdevDef *dev, - const char *backendAlias); + const char *backendAlias, + virQEMUCaps *qemuCaps); qemuBlockStorageSourceAttachData * qemuBuildHostdevSCSIAttachPrepare(virDomainHostdevDef *hostdev, @@ -197,7 +198,8 @@ qemuBuildSCSIVHostHostdevDevProps(const virDomainDef *def, virJSONValue * qemuBuildHostdevMediatedDevProps(const virDomainDef *def, - virDomainHostdevDef *dev); + virDomainHostdevDef *dev, + virQEMUCaps *qemuCaps); virJSONValue * qemuBuildRedirdevDevProps(const virDomainDef *def, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 1a7b69e5bb..5db72ef634 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2541,7 +2541,8 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriver *driver, priv->qemuCaps))) goto cleanup; - if (!(devprops = qemuBuildSCSIHostdevDevProps(vm->def, hostdev, backendalias))) + if (!(devprops = qemuBuildSCSIHostdevDevProps(vm->def, hostdev, backendalias, + priv->qemuCaps))) goto cleanup; VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1); @@ -2761,7 +2762,8 @@ qemuDomainAttachMediatedDevice(virQEMUDriver *driver, qemuAssignDeviceHostdevAlias(vm->def, &hostdev->info->alias, -1); - if (!(devprops = qemuBuildHostdevMediatedDevProps(vm->def, hostdev))) + if (!(devprops = qemuBuildHostdevMediatedDevProps(vm->def, hostdev, + priv->qemuCaps))) goto cleanup; VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1); diff --git a/tests/qemuxmlconfdata/machine-loadparm-hostdev.s390x-9.1.0.args b/tests/qemuxmlconfdata/machine-loadparm-hostdev.s390x-9.1.0.args new file mode 100644 index 0000000000..0a025e6335 --- /dev/null +++ b/tests/qemuxmlconfdata/machine-loadparm-hostdev.s390x-9.1.0.args @@ -0,0 +1,33 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1 \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \ +/usr/bin/qemu-system-s390x \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-QEMUGuest1/master-key.aes"}' \ +-machine s390-ccw-virtio-9.1,usb=off,dump-guest-core=off,memory-backend=s390.ram,loadparm=2 \ +-accel tcg \ +-cpu qemu \ +-m size=524288k \ +-object '{"qom-type":"memory-backend-ram","id":"s390.ram","size":536870912}' \ +-overcommit mem-lock=off \ +-smp 2,sockets=2,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-boot strict=on \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-device '{"driver":"vfio-ccw","id":"hostdev0","sysfsdev":"/sys/bus/mdev/devices/90c6c135-ad44-41d0-b1b7-bae47de48627","bootindex":1,"devno":"fe.0.0000"}' \ +-device '{"driver":"virtio-balloon-ccw","id":"balloon0","devno":"fe.0.0001"}' \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxmlconfdata/machine-loadparm-hostdev.s390x-9.1.0.xml b/tests/qemuxmlconfdata/machine-loadparm-hostdev.s390x-9.1.0.xml new file mode 100644 index 0000000000..119ae6b0fa --- /dev/null +++ b/tests/qemuxmlconfdata/machine-loadparm-hostdev.s390x-9.1.0.xml @@ -0,0 +1,33 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 524288 + 524288 + 2 + + hvm + + + qemu + + + destroy + restart + destroy + + /usr/bin/qemu-system-s390x + +