If QEMU supports multi boot device make use of it instead of using the
single boot device machine parameter.
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
---
src/qemu/qemu_command.c | 40 ++++++++++++---
src/qemu/qemu_command.h | 6 ++-
src/qemu/qemu_hotplug.c | 6 ++-
.../machine-loadparm-hostdev.s390x-9.1.0.args | 33 ++++++++++++
.../machine-loadparm-hostdev.s390x-9.1.0.xml | 33 ++++++++++++
...machine-loadparm-hostdev.s390x-latest.args | 4 +-
...-multiple-disks-nets-s390.s390x-9.1.0.args | 40 +++++++++++++++
...m-multiple-disks-nets-s390.s390x-9.1.0.xml | 51 +++++++++++++++++++
...multiple-disks-nets-s390.s390x-latest.args | 8 +--
...machine-loadparm-net-s390.s390x-9.1.0.args | 34 +++++++++++++
.../machine-loadparm-net-s390.s390x-9.1.0.xml | 32 ++++++++++++
...achine-loadparm-net-s390.s390x-latest.args | 4 +-
.../machine-loadparm-s390.s390x-9.1.0.args | 34 +++++++++++++
.../machine-loadparm-s390.s390x-9.1.0.xml | 33 ++++++++++++
.../machine-loadparm-s390.s390x-latest.args | 4 +-
tests/qemuxmlconftest.c | 4 ++
16 files changed, 346 insertions(+), 20 deletions(-)
create mode 100644 tests/qemuxmlconfdata/machine-loadparm-hostdev.s390x-9.1.0.args
create mode 100644 tests/qemuxmlconfdata/machine-loadparm-hostdev.s390x-9.1.0.xml
create mode 100644 tests/qemuxmlconfdata/machine-loadparm-multiple-disks-nets-s390.s390x-9.1.0.args
create mode 100644 tests/qemuxmlconfdata/machine-loadparm-multiple-disks-nets-s390.s390x-9.1.0.xml
create mode 100644 tests/qemuxmlconfdata/machine-loadparm-net-s390.s390x-9.1.0.args
create mode 100644 tests/qemuxmlconfdata/machine-loadparm-net-s390.s390x-9.1.0.xml
create mode 100644 tests/qemuxmlconfdata/machine-loadparm-s390.s390x-9.1.0.args
create mode 100644 tests/qemuxmlconfdata/machine-loadparm-s390.s390x-9.1.0.xml
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index a5ff7695c3..cdc0ea18d7 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;
+ g_autofree 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,14 @@ 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 (disk->info.loadparm &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW_DEVICE_LOADPARM))
+ bootLoadparm = g_strdup(disk->info.loadparm);
+ }
+
if (disk->wwn) {
unsigned long long w = 0;
@@ -1791,6 +1797,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 +3623,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);
+ g_autofree char *bootLoadparm = NULL;
if (virDomainNetIsVirtioModel(net)) {
const char *tx = NULL;
@@ -3701,11 +3709,16 @@ qemuBuildNicDevProps(virDomainDef *def,
virMacAddrFormat(&net->mac, macaddr);
+ if (net->info.loadparm &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW_DEVICE_LOADPARM))
+ bootLoadparm = g_strdup(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 +4764,22 @@ qemuBuildSCSIVHostHostdevDevProps(const virDomainDef *def,
virJSONValue *
qemuBuildSCSIHostdevDevProps(const virDomainDef *def,
virDomainHostdevDef *dev,
- const char *backendAlias)
+ const char *backendAlias,
+ virQEMUCaps *qemuCaps)
{
+ g_autofree char *bootLoadparm = NULL;
g_autoptr(virJSONValue) props = NULL;
+ if (dev->info->loadparm &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW_DEVICE_LOADPARM))
+ bootLoadparm = g_strdup(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 +4860,22 @@ 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;
+ g_autofree 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 (dev->info->loadparm &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW_DEVICE_LOADPARM))
+ bootLoadparm = g_strdup(dev->info->loadparm);
+
if (virJSONValueObjectAdd(&props,
"s:driver", qemuBuildHostdevMdevModelTypeString(mdevsrc),
"s:id", dev->info->alias,
@@ -4857,6 +4883,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 +4982,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 +5081,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 +6906,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 @@
+<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'>2</vcpu>
+ <os>
+ <type arch='s390x' machine='s390-ccw-virtio-9.1'>hvm</type>
+ </os>
+ <cpu mode='custom' match='exact' check='none'>
+ <model fallback='forbid'>qemu</model>
+ </cpu>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-s390x</emulator>
+ <controller type='pci' index='0' model='pci-root'/>
+ <audio id='1' type='none'/>
+ <hostdev mode='subsystem' type='mdev' managed='no' model='vfio-ccw'>
+ <source>
+ <address uuid='90c6c135-ad44-41d0-b1b7-bae47de48627'/>
+ </source>
+ <boot order='1' loadparm='2'/>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
+ </hostdev>
+ <memballoon model='virtio'>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0001'/>
+ </memballoon>
+ <panic model='s390'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxmlconfdata/machine-loadparm-hostdev.s390x-latest.args b/tests/qemuxmlconfdata/machine-loadparm-hostdev.s390x-latest.args
index 3580db8e21..39f77c14e7 100644
--- a/tests/qemuxmlconfdata/machine-loadparm-hostdev.s390x-latest.args
+++ b/tests/qemuxmlconfdata/machine-loadparm-hostdev.s390x-latest.args
@@ -10,7 +10,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
-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,usb=off,dump-guest-core=off,memory-backend=s390.ram,loadparm=2 \
+-machine s390-ccw-virtio,usb=off,dump-guest-core=off,memory-backend=s390.ram \
-accel tcg \
-cpu qemu \
-m size=524288k \
@@ -27,7 +27,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
-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":"vfio-ccw","id":"hostdev0","sysfsdev":"/sys/bus/mdev/devices/90c6c135-ad44-41d0-b1b7-bae47de48627","bootindex":1,"loadparm":"2","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-multiple-disks-nets-s390.s390x-9.1.0.args b/tests/qemuxmlconfdata/machine-loadparm-multiple-disks-nets-s390.s390x-9.1.0.args
new file mode 100644
index 0000000000..02c0612440
--- /dev/null
+++ b/tests/qemuxmlconfdata/machine-loadparm-multiple-disks-nets-s390.s390x-9.1.0.args
@@ -0,0 +1,40 @@
+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=SYSTEM1 \
+-accel tcg \
+-cpu qemu \
+-m size=219136k \
+-object '{"qom-type":"memory-backend-ram","id":"s390.ram","size":224395264}' \
+-overcommit mem-lock=off \
+-smp 1,sockets=1,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 \
+-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","node-name":"libvirt-2-storage","read-only":false}' \
+-device '{"driver":"virtio-blk-ccw","devno":"fe.0.0002","drive":"libvirt-2-storage","id":"virtio-disk0","bootindex":1}' \
+-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest2","node-name":"libvirt-1-storage","read-only":false}' \
+-device '{"driver":"virtio-blk-ccw","devno":"fe.0.0003","drive":"libvirt-1-storage","id":"virtio-disk1","bootindex":3}' \
+-netdev '{"type":"user","id":"hostnet0"}' \
+-device '{"driver":"virtio-net-ccw","netdev":"hostnet0","id":"net0","mac":"00:11:22:33:44:54","bootindex":2,"devno":"fe.0.0000"}' \
+-netdev '{"type":"user","id":"hostnet1"}' \
+-device '{"driver":"virtio-net-ccw","netdev":"hostnet1","id":"net1","mac":"00:11:22:33:42:36","devno":"fe.0.0004"}' \
+-audiodev '{"id":"audio1","driver":"none"}' \
+-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-multiple-disks-nets-s390.s390x-9.1.0.xml b/tests/qemuxmlconfdata/machine-loadparm-multiple-disks-nets-s390.s390x-9.1.0.xml
new file mode 100644
index 0000000000..9e108062ce
--- /dev/null
+++ b/tests/qemuxmlconfdata/machine-loadparm-multiple-disks-nets-s390.s390x-9.1.0.xml
@@ -0,0 +1,51 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='s390x' machine='s390-ccw-virtio-9.1'>hvm</type>
+ </os>
+ <cpu mode='custom' match='exact' check='none'>
+ <model fallback='forbid'>qemu</model>
+ </cpu>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-s390x</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='virtio'/>
+ <boot order='1' loadparm='SYSTEM1'/>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0002'/>
+ </disk>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest2'/>
+ <target dev='hdb' bus='virtio'/>
+ <boot order='3' loadparm='3'/>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0003'/>
+ </disk>
+ <controller type='pci' index='0' model='pci-root'/>
+ <interface type='user'>
+ <mac address='00:11:22:33:44:54'/>
+ <model type='virtio'/>
+ <boot order='2' loadparm='2.LP'/>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='00:11:22:33:42:36'/>
+ <model type='virtio'/>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0004'/>
+ </interface>
+ <audio id='1' type='none'/>
+ <memballoon model='virtio'>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0001'/>
+ </memballoon>
+ <panic model='s390'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxmlconfdata/machine-loadparm-multiple-disks-nets-s390.s390x-latest.args b/tests/qemuxmlconfdata/machine-loadparm-multiple-disks-nets-s390.s390x-latest.args
index 411b62f3ee..34f148e430 100644
--- a/tests/qemuxmlconfdata/machine-loadparm-multiple-disks-nets-s390.s390x-latest.args
+++ b/tests/qemuxmlconfdata/machine-loadparm-multiple-disks-nets-s390.s390x-latest.args
@@ -10,7 +10,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
-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,usb=off,dump-guest-core=off,memory-backend=s390.ram,loadparm=SYSTEM1 \
+-machine s390-ccw-virtio,usb=off,dump-guest-core=off,memory-backend=s390.ram \
-accel tcg \
-cpu qemu \
-m size=219136k \
@@ -27,11 +27,11 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
-no-shutdown \
-boot strict=on \
-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","node-name":"libvirt-2-storage","read-only":false}' \
--device '{"driver":"virtio-blk-ccw","devno":"fe.0.0002","drive":"libvirt-2-storage","id":"virtio-disk0","bootindex":1}' \
+-device '{"driver":"virtio-blk-ccw","devno":"fe.0.0002","drive":"libvirt-2-storage","id":"virtio-disk0","bootindex":1,"loadparm":"SYSTEM1"}' \
-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest2","node-name":"libvirt-1-storage","read-only":false}' \
--device '{"driver":"virtio-blk-ccw","devno":"fe.0.0003","drive":"libvirt-1-storage","id":"virtio-disk1","bootindex":3}' \
+-device '{"driver":"virtio-blk-ccw","devno":"fe.0.0003","drive":"libvirt-1-storage","id":"virtio-disk1","bootindex":3,"loadparm":"3"}' \
-netdev '{"type":"user","id":"hostnet0"}' \
--device '{"driver":"virtio-net-ccw","netdev":"hostnet0","id":"net0","mac":"00:11:22:33:44:54","bootindex":2,"devno":"fe.0.0000"}' \
+-device '{"driver":"virtio-net-ccw","netdev":"hostnet0","id":"net0","mac":"00:11:22:33:44:54","bootindex":2,"loadparm":"2.LP","devno":"fe.0.0000"}' \
-netdev '{"type":"user","id":"hostnet1"}' \
-device '{"driver":"virtio-net-ccw","netdev":"hostnet1","id":"net1","mac":"00:11:22:33:42:36","devno":"fe.0.0004"}' \
-audiodev '{"id":"audio1","driver":"none"}' \
diff --git a/tests/qemuxmlconfdata/machine-loadparm-net-s390.s390x-9.1.0.args b/tests/qemuxmlconfdata/machine-loadparm-net-s390.s390x-9.1.0.args
new file mode 100644
index 0000000000..4d34784f46
--- /dev/null
+++ b/tests/qemuxmlconfdata/machine-loadparm-net-s390.s390x-9.1.0.args
@@ -0,0 +1,34 @@
+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=219136k \
+-object '{"qom-type":"memory-backend-ram","id":"s390.ram","size":224395264}' \
+-overcommit mem-lock=off \
+-smp 1,sockets=1,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 \
+-netdev '{"type":"user","id":"hostnet0"}' \
+-device '{"driver":"virtio-net-ccw","netdev":"hostnet0","id":"net0","mac":"00:11:22:33:44:54","bootindex":1,"devno":"fe.0.0000"}' \
+-audiodev '{"id":"audio1","driver":"none"}' \
+-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-net-s390.s390x-9.1.0.xml b/tests/qemuxmlconfdata/machine-loadparm-net-s390.s390x-9.1.0.xml
new file mode 100644
index 0000000000..3c2dc60dd1
--- /dev/null
+++ b/tests/qemuxmlconfdata/machine-loadparm-net-s390.s390x-9.1.0.xml
@@ -0,0 +1,32 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='s390x' machine='s390-ccw-virtio-9.1'>hvm</type>
+ </os>
+ <cpu mode='custom' match='exact' check='none'>
+ <model fallback='forbid'>qemu</model>
+ </cpu>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-s390x</emulator>
+ <controller type='pci' index='0' model='pci-root'/>
+ <interface type='user'>
+ <mac address='00:11:22:33:44:54'/>
+ <model type='virtio'/>
+ <boot order='1' loadparm='2'/>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
+ </interface>
+ <audio id='1' type='none'/>
+ <memballoon model='virtio'>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0001'/>
+ </memballoon>
+ <panic model='s390'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxmlconfdata/machine-loadparm-net-s390.s390x-latest.args b/tests/qemuxmlconfdata/machine-loadparm-net-s390.s390x-latest.args
index bdd2782f5a..a5241c38f3 100644
--- a/tests/qemuxmlconfdata/machine-loadparm-net-s390.s390x-latest.args
+++ b/tests/qemuxmlconfdata/machine-loadparm-net-s390.s390x-latest.args
@@ -10,7 +10,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
-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,usb=off,dump-guest-core=off,memory-backend=s390.ram,loadparm=2 \
+-machine s390-ccw-virtio,usb=off,dump-guest-core=off,memory-backend=s390.ram \
-accel tcg \
-cpu qemu \
-m size=219136k \
@@ -27,7 +27,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
-no-shutdown \
-boot strict=on \
-netdev '{"type":"user","id":"hostnet0"}' \
--device '{"driver":"virtio-net-ccw","netdev":"hostnet0","id":"net0","mac":"00:11:22:33:44:54","bootindex":1,"devno":"fe.0.0000"}' \
+-device '{"driver":"virtio-net-ccw","netdev":"hostnet0","id":"net0","mac":"00:11:22:33:44:54","bootindex":1,"loadparm":"2","devno":"fe.0.0000"}' \
-audiodev '{"id":"audio1","driver":"none"}' \
-device '{"driver":"virtio-balloon-ccw","id":"balloon0","devno":"fe.0.0001"}' \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
diff --git a/tests/qemuxmlconfdata/machine-loadparm-s390.s390x-9.1.0.args b/tests/qemuxmlconfdata/machine-loadparm-s390.s390x-9.1.0.args
new file mode 100644
index 0000000000..cbb5e9df34
--- /dev/null
+++ b/tests/qemuxmlconfdata/machine-loadparm-s390.s390x-9.1.0.args
@@ -0,0 +1,34 @@
+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=219136k \
+-object '{"qom-type":"memory-backend-ram","id":"s390.ram","size":224395264}' \
+-overcommit mem-lock=off \
+-smp 1,sockets=1,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 \
+-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","node-name":"libvirt-1-storage","read-only":false}' \
+-device '{"driver":"virtio-blk-ccw","devno":"fe.0.0000","drive":"libvirt-1-storage","id":"virtio-disk0","bootindex":1}' \
+-audiodev '{"id":"audio1","driver":"none"}' \
+-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-s390.s390x-9.1.0.xml b/tests/qemuxmlconfdata/machine-loadparm-s390.s390x-9.1.0.xml
new file mode 100644
index 0000000000..994888a05e
--- /dev/null
+++ b/tests/qemuxmlconfdata/machine-loadparm-s390.s390x-9.1.0.xml
@@ -0,0 +1,33 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='s390x' machine='s390-ccw-virtio-9.1'>hvm</type>
+ </os>
+ <cpu mode='custom' match='exact' check='none'>
+ <model fallback='forbid'>qemu</model>
+ </cpu>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-s390x</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='virtio'/>
+ <boot order='1' loadparm='2'/>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
+ </disk>
+ <controller type='pci' index='0' model='pci-root'/>
+ <audio id='1' type='none'/>
+ <memballoon model='virtio'>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0001'/>
+ </memballoon>
+ <panic model='s390'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxmlconfdata/machine-loadparm-s390.s390x-latest.args b/tests/qemuxmlconfdata/machine-loadparm-s390.s390x-latest.args
index 896fc1e578..2b46f1b83f 100644
--- a/tests/qemuxmlconfdata/machine-loadparm-s390.s390x-latest.args
+++ b/tests/qemuxmlconfdata/machine-loadparm-s390.s390x-latest.args
@@ -10,7 +10,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
-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,usb=off,dump-guest-core=off,memory-backend=s390.ram,loadparm=2 \
+-machine s390-ccw-virtio,usb=off,dump-guest-core=off,memory-backend=s390.ram \
-accel tcg \
-cpu qemu \
-m size=219136k \
@@ -27,7 +27,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
-no-shutdown \
-boot strict=on \
-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","node-name":"libvirt-1-storage","read-only":false}' \
--device '{"driver":"virtio-blk-ccw","devno":"fe.0.0000","drive":"libvirt-1-storage","id":"virtio-disk0","bootindex":1}' \
+-device '{"driver":"virtio-blk-ccw","devno":"fe.0.0000","drive":"libvirt-1-storage","id":"virtio-disk0","bootindex":1,"loadparm":"2"}' \
-audiodev '{"id":"audio1","driver":"none"}' \
-device '{"driver":"virtio-balloon-ccw","id":"balloon0","devno":"fe.0.0001"}' \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c
index 9bcd937447..e9c8d0c552 100644
--- a/tests/qemuxmlconftest.c
+++ b/tests/qemuxmlconftest.c
@@ -2721,9 +2721,13 @@ mymain(void)
DO_TEST_CAPS_ARCH_LATEST("machine-keywrap-none", "s390x");
DO_TEST_CAPS_ARCH_LATEST("machine-loadparm-s390", "s390x");
+ DO_TEST_CAPS_ARCH_VER("machine-loadparm-s390", "s390x", "9.1.0");
DO_TEST_CAPS_ARCH_LATEST("machine-loadparm-net-s390", "s390x");
+ DO_TEST_CAPS_ARCH_VER("machine-loadparm-net-s390", "s390x", "9.1.0");
DO_TEST_CAPS_ARCH_LATEST("machine-loadparm-hostdev", "s390x");
+ DO_TEST_CAPS_ARCH_VER("machine-loadparm-hostdev", "s390x", "9.1.0");
DO_TEST_CAPS_ARCH_LATEST("machine-loadparm-multiple-disks-nets-s390", "s390x");
+ DO_TEST_CAPS_ARCH_VER("machine-loadparm-multiple-disks-nets-s390", "s390x", "9.1.0");
DO_TEST_CAPS_LATEST_PARSE_ERROR("machine-loadparm-s390-char-invalid");
DO_TEST_CAPS_LATEST_PARSE_ERROR("machine-loadparm-s390-len-invalid");
--
2.45.0
On Wed, Nov 06, 2024 at 15:31:57 +0100, Boris Fiuczynski wrote: > If QEMU supports multi boot device make use of it instead of using the > single boot device machine parameter. > > Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com> > --- > src/qemu/qemu_command.c | 40 ++++++++++++--- > src/qemu/qemu_command.h | 6 ++- > src/qemu/qemu_hotplug.c | 6 ++- > .../machine-loadparm-hostdev.s390x-9.1.0.args | 33 ++++++++++++ > .../machine-loadparm-hostdev.s390x-9.1.0.xml | 33 ++++++++++++ > ...machine-loadparm-hostdev.s390x-latest.args | 4 +- > ...-multiple-disks-nets-s390.s390x-9.1.0.args | 40 +++++++++++++++ > ...m-multiple-disks-nets-s390.s390x-9.1.0.xml | 51 +++++++++++++++++++ > ...multiple-disks-nets-s390.s390x-latest.args | 8 +-- > ...machine-loadparm-net-s390.s390x-9.1.0.args | 34 +++++++++++++ > .../machine-loadparm-net-s390.s390x-9.1.0.xml | 32 ++++++++++++ > ...achine-loadparm-net-s390.s390x-latest.args | 4 +- > .../machine-loadparm-s390.s390x-9.1.0.args | 34 +++++++++++++ > .../machine-loadparm-s390.s390x-9.1.0.xml | 33 ++++++++++++ > .../machine-loadparm-s390.s390x-latest.args | 4 +- > tests/qemuxmlconftest.c | 4 ++ > 16 files changed, 346 insertions(+), 20 deletions(-) > create mode 100644 tests/qemuxmlconfdata/machine-loadparm-hostdev.s390x-9.1.0.args > create mode 100644 tests/qemuxmlconfdata/machine-loadparm-hostdev.s390x-9.1.0.xml > create mode 100644 tests/qemuxmlconfdata/machine-loadparm-multiple-disks-nets-s390.s390x-9.1.0.args > create mode 100644 tests/qemuxmlconfdata/machine-loadparm-multiple-disks-nets-s390.s390x-9.1.0.xml > create mode 100644 tests/qemuxmlconfdata/machine-loadparm-net-s390.s390x-9.1.0.args > create mode 100644 tests/qemuxmlconfdata/machine-loadparm-net-s390.s390x-9.1.0.xml > create mode 100644 tests/qemuxmlconfdata/machine-loadparm-s390.s390x-9.1.0.args > create mode 100644 tests/qemuxmlconfdata/machine-loadparm-s390.s390x-9.1.0.xml > > diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c > index a5ff7695c3..cdc0ea18d7 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; > + g_autofree 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,14 @@ 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 (disk->info.loadparm && > + virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW_DEVICE_LOADPARM)) > + bootLoadparm = g_strdup(disk->info.loadparm); You don't need to copy this .... > + } > + > if (disk->wwn) { > unsigned long long w = 0; > > @@ -1791,6 +1797,7 @@ qemuBuildDiskDeviceProps(const virDomainDef *def, > "S:chardev", chardev, > "s:id", disk->info.alias, > "p:bootindex", bootindex, > + "S:loadparm", bootLoadparm, ... to pass it here. This takes const strings and copies them internally into the JSON buffer regardless. Just assign the pointer without copy. You also don't need to check that the string is non-NULL before passing it to g_strdup, or once you remove g_strdup to the temporary pointer. Looking at how the parsing of loadparm is handled I guess we still need to keep the capability (it' can't be moved into post-parse).
On 11/7/24 15:53, Peter Krempa wrote: > On Wed, Nov 06, 2024 at 15:31:57 +0100, Boris Fiuczynski wrote: >> If QEMU supports multi boot device make use of it instead of using the >> single boot device machine parameter. >> >> Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com> >> --- >> src/qemu/qemu_command.c | 40 ++++++++++++--- >> src/qemu/qemu_command.h | 6 ++- >> src/qemu/qemu_hotplug.c | 6 ++- >> .../machine-loadparm-hostdev.s390x-9.1.0.args | 33 ++++++++++++ >> .../machine-loadparm-hostdev.s390x-9.1.0.xml | 33 ++++++++++++ >> ...machine-loadparm-hostdev.s390x-latest.args | 4 +- >> ...-multiple-disks-nets-s390.s390x-9.1.0.args | 40 +++++++++++++++ >> ...m-multiple-disks-nets-s390.s390x-9.1.0.xml | 51 +++++++++++++++++++ >> ...multiple-disks-nets-s390.s390x-latest.args | 8 +-- >> ...machine-loadparm-net-s390.s390x-9.1.0.args | 34 +++++++++++++ >> .../machine-loadparm-net-s390.s390x-9.1.0.xml | 32 ++++++++++++ >> ...achine-loadparm-net-s390.s390x-latest.args | 4 +- >> .../machine-loadparm-s390.s390x-9.1.0.args | 34 +++++++++++++ >> .../machine-loadparm-s390.s390x-9.1.0.xml | 33 ++++++++++++ >> .../machine-loadparm-s390.s390x-latest.args | 4 +- >> tests/qemuxmlconftest.c | 4 ++ >> 16 files changed, 346 insertions(+), 20 deletions(-) >> create mode 100644 tests/qemuxmlconfdata/machine-loadparm-hostdev.s390x-9.1.0.args >> create mode 100644 tests/qemuxmlconfdata/machine-loadparm-hostdev.s390x-9.1.0.xml >> create mode 100644 tests/qemuxmlconfdata/machine-loadparm-multiple-disks-nets-s390.s390x-9.1.0.args >> create mode 100644 tests/qemuxmlconfdata/machine-loadparm-multiple-disks-nets-s390.s390x-9.1.0.xml >> create mode 100644 tests/qemuxmlconfdata/machine-loadparm-net-s390.s390x-9.1.0.args >> create mode 100644 tests/qemuxmlconfdata/machine-loadparm-net-s390.s390x-9.1.0.xml >> create mode 100644 tests/qemuxmlconfdata/machine-loadparm-s390.s390x-9.1.0.args >> create mode 100644 tests/qemuxmlconfdata/machine-loadparm-s390.s390x-9.1.0.xml >> >> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c >> index a5ff7695c3..cdc0ea18d7 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; >> + g_autofree 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,14 @@ 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 (disk->info.loadparm && >> + virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW_DEVICE_LOADPARM)) >> + bootLoadparm = g_strdup(disk->info.loadparm); > > You don't need to copy this .... > >> + } >> + >> if (disk->wwn) { >> unsigned long long w = 0; >> >> @@ -1791,6 +1797,7 @@ qemuBuildDiskDeviceProps(const virDomainDef *def, >> "S:chardev", chardev, >> "s:id", disk->info.alias, >> "p:bootindex", bootindex, >> + "S:loadparm", bootLoadparm, > > ... to pass it here. This takes const strings and copies them internally > into the JSON buffer regardless. > > Just assign the pointer without copy. You also don't need to check that > the string is non-NULL before passing it to g_strdup, or once you remove > g_strdup to the temporary pointer. > > Looking at how the parsing of loadparm is handled I guess we still need > to keep the capability (it' can't be moved into post-parse). OK, will do this here and also the other three similar instances. With fixups just like this: diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index cdc0ea18d7..f67176fbfd 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1608,7 +1608,7 @@ qemuBuildDiskDeviceProps(const virDomainDef *def, g_autofree char *chardev = NULL; g_autofree char *drive = NULL; unsigned int bootindex = 0; - g_autofree char *bootLoadparm = NULL; + 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; @@ -1750,9 +1750,8 @@ qemuBuildDiskDeviceProps(const virDomainDef *def, if (disk->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY) { bootindex = disk->info.effectiveBootIndex; - if (disk->info.loadparm && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW_DEVICE_LOADPARM)) - bootLoadparm = g_strdup(disk->info.loadparm); + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW_DEVICE_LOADPARM)) + bootLoadparm = disk->info.loadparm; } if (disk->wwn) { -- Mit freundlichen Grüßen/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Wolfgang Wendt Geschäftsführung: David Faller Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294
On Thu, Nov 07, 2024 at 17:01:52 +0100, Boris Fiuczynski wrote: > On 11/7/24 15:53, Peter Krempa wrote: > > On Wed, Nov 06, 2024 at 15:31:57 +0100, Boris Fiuczynski wrote: > > > If QEMU supports multi boot device make use of it instead of using the > > > single boot device machine parameter. > > > > > > Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com> > > > --- [...] > > OK, will do this here and also the other three similar instances. > With fixups just like this: > diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c > index cdc0ea18d7..f67176fbfd 100644 > --- a/src/qemu/qemu_command.c > +++ b/src/qemu/qemu_command.c > @@ -1608,7 +1608,7 @@ qemuBuildDiskDeviceProps(const virDomainDef *def, > g_autofree char *chardev = NULL; > g_autofree char *drive = NULL; > unsigned int bootindex = 0; > - g_autofree char *bootLoadparm = NULL; > + 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; > @@ -1750,9 +1750,8 @@ qemuBuildDiskDeviceProps(const virDomainDef *def, > if (disk->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY) { > bootindex = disk->info.effectiveBootIndex; > > - if (disk->info.loadparm && > - virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW_DEVICE_LOADPARM)) > - bootLoadparm = g_strdup(disk->info.loadparm); > + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW_DEVICE_LOADPARM)) > + bootLoadparm = disk->info.loadparm; > } With that: Reviewed-by: Peter Krempa <pkrempa@redhat.com>
© 2016 - 2024 Red Hat, Inc.