mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 23:07:44 +00:00
qemu: wire up command line support for ACPI index
This makes it possible to enable stable NIC device names in most modern Linux distros. Reviewed-by: Peter Krempa <pkrempa@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
1b80c6f0d0
commit
ffda44030a
@ -420,6 +420,8 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
|
|||||||
virBufferAsprintf(buf, ",addr=0x%x", info->addr.pci.slot);
|
virBufferAsprintf(buf, ",addr=0x%x", info->addr.pci.slot);
|
||||||
if (info->addr.pci.function != 0)
|
if (info->addr.pci.function != 0)
|
||||||
virBufferAsprintf(buf, ".0x%x", info->addr.pci.function);
|
virBufferAsprintf(buf, ".0x%x", info->addr.pci.function);
|
||||||
|
if (info->acpiIndex != 0)
|
||||||
|
virBufferAsprintf(buf, ",acpi-index=%u", info->acpiIndex);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1069,6 +1069,32 @@ qemuValidateDomainDefPanic(const virDomainDef *def,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuValidateDomainDeviceInfo(virDomainDefPtr def G_GNUC_UNUSED,
|
||||||
|
virDomainDeviceDefPtr dev G_GNUC_UNUSED,
|
||||||
|
virDomainDeviceInfoPtr info,
|
||||||
|
void *opaque)
|
||||||
|
{
|
||||||
|
virQEMUCapsPtr qemuCaps = opaque;
|
||||||
|
|
||||||
|
if (info->acpiIndex) {
|
||||||
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_ACPI_INDEX)) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("ACPI index is not supported with this QEMU"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
|
||||||
|
info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("ACPI index is only supported for PCI devices"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
qemuValidateDomainDef(const virDomainDef *def,
|
qemuValidateDomainDef(const virDomainDef *def,
|
||||||
void *opaque,
|
void *opaque,
|
||||||
@ -1235,6 +1261,15 @@ qemuValidateDomainDef(const virDomainDef *def,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Explicitly discarding 'const' from 'def' is ok because
|
||||||
|
* we know our callback qemuValidateDomainDeviceInfo will
|
||||||
|
* not modify it
|
||||||
|
*/
|
||||||
|
if (virDomainDeviceInfoIterate((virDomainDefPtr)def,
|
||||||
|
qemuValidateDomainDeviceInfo,
|
||||||
|
qemuCaps) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
57
tests/qemuxml2argvdata/devices-acpi-index.x86_64-latest.args
Normal file
57
tests/qemuxml2argvdata/devices-acpi-index.x86_64-latest.args
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
LC_ALL=C \
|
||||||
|
PATH=/bin \
|
||||||
|
HOME=/tmp/lib/domain--1-fdr-br \
|
||||||
|
USER=test \
|
||||||
|
LOGNAME=test \
|
||||||
|
XDG_DATA_HOME=/tmp/lib/domain--1-fdr-br/.local/share \
|
||||||
|
XDG_CACHE_HOME=/tmp/lib/domain--1-fdr-br/.cache \
|
||||||
|
XDG_CONFIG_HOME=/tmp/lib/domain--1-fdr-br/.config \
|
||||||
|
/usr/bin/qemu-system-x86_64 \
|
||||||
|
-name guest=fdr-br,debug-threads=on \
|
||||||
|
-S \
|
||||||
|
-object '{"qom-type":"secret","id":"masterKey0","format":"raw",\
|
||||||
|
"file":"/tmp/lib/domain--1-fdr-br/master-key.aes"}' \
|
||||||
|
-machine pc-i440fx-5.0,accel=tcg,usb=off,dump-guest-core=off,\
|
||||||
|
memory-backend=pc.ram \
|
||||||
|
-cpu qemu64 \
|
||||||
|
-m 2048 \
|
||||||
|
-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":2147483648}' \
|
||||||
|
-overcommit mem-lock=off \
|
||||||
|
-smp 2,sockets=2,cores=1,threads=1 \
|
||||||
|
-uuid 3ec6cbe1-b5a2-4515-b800-31a61855df41 \
|
||||||
|
-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 \
|
||||||
|
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
|
||||||
|
-blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/test.img",\
|
||||||
|
"node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \
|
||||||
|
-blockdev '{"node-name":"libvirt-2-format","read-only":false,"driver":"raw",\
|
||||||
|
"file":"libvirt-2-storage"}' \
|
||||||
|
-device virtio-blk-pci,bus=pci.0,addr=0x3,acpi-index=1,drive=libvirt-2-format,\
|
||||||
|
id=virtio-disk0,bootindex=1 \
|
||||||
|
-blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/test1.img",\
|
||||||
|
"node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \
|
||||||
|
-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw",\
|
||||||
|
"file":"libvirt-1-storage"}' \
|
||||||
|
-device virtio-blk-pci,bus=pci.0,addr=0x4,acpi-index=42,drive=libvirt-1-format,\
|
||||||
|
id=virtio-disk1 \
|
||||||
|
-netdev user,id=hostnet0 \
|
||||||
|
-device virtio-net-pci,netdev=hostnet0,id=net0,mac=00:11:22:33:44:55,bus=pci.0,\
|
||||||
|
addr=0x5,acpi-index=100 \
|
||||||
|
-netdev user,id=hostnet1 \
|
||||||
|
-device virtio-net-pci,netdev=hostnet1,id=net1,mac=00:11:22:33:44:55,bus=pci.0,\
|
||||||
|
addr=0x7,acpi-index=200 \
|
||||||
|
-netdev user,id=hostnet2 \
|
||||||
|
-device virtio-net-pci,netdev=hostnet2,id=net2,mac=00:11:22:33:44:55,bus=pci.0,\
|
||||||
|
addr=0x8,acpi-index=300 \
|
||||||
|
-audiodev id=audio1,driver=none \
|
||||||
|
-device cirrus-vga,id=video0,bus=pci.0,addr=0x2,acpi-index=1729 \
|
||||||
|
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6 \
|
||||||
|
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
|
||||||
|
resourcecontrol=deny \
|
||||||
|
-msg timestamp=on
|
62
tests/qemuxml2argvdata/devices-acpi-index.xml
Normal file
62
tests/qemuxml2argvdata/devices-acpi-index.xml
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<domain type='qemu'>
|
||||||
|
<name>fdr-br</name>
|
||||||
|
<uuid>3ec6cbe1-b5a2-4515-b800-31a61855df41</uuid>
|
||||||
|
<memory unit='KiB'>2097152</memory>
|
||||||
|
<currentMemory unit='KiB'>2097152</currentMemory>
|
||||||
|
<vcpu placement='static' cpuset='0-1'>2</vcpu>
|
||||||
|
<os>
|
||||||
|
<type arch='x86_64' machine='pc-i440fx-5.0'>hvm</type>
|
||||||
|
<boot dev='hd'/>
|
||||||
|
</os>
|
||||||
|
<features>
|
||||||
|
<acpi/>
|
||||||
|
<apic/>
|
||||||
|
<pae/>
|
||||||
|
</features>
|
||||||
|
<clock offset='utc'/>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>restart</on_crash>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/bin/qemu-system-x86_64</emulator>
|
||||||
|
<disk type='file' device='disk'>
|
||||||
|
<driver name='qemu' type='raw'/>
|
||||||
|
<source file='/var/lib/libvirt/images/test.img'/>
|
||||||
|
<target dev='vda' bus='virtio'/>
|
||||||
|
<acpi index='1'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
|
||||||
|
</disk>
|
||||||
|
<disk type='file' device='disk'>
|
||||||
|
<driver name='qemu' type='raw'/>
|
||||||
|
<source file='/var/lib/libvirt/images/test1.img'/>
|
||||||
|
<target dev='vdb' bus='virtio'/>
|
||||||
|
<acpi index='42'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
|
||||||
|
</disk>
|
||||||
|
<interface type='user'>
|
||||||
|
<mac address='00:11:22:33:44:55'/>
|
||||||
|
<acpi index='100'/>
|
||||||
|
<model type='virtio'/>
|
||||||
|
</interface>
|
||||||
|
<interface type='user'>
|
||||||
|
<mac address='00:11:22:33:44:55'/>
|
||||||
|
<acpi index='200'/>
|
||||||
|
<model type='virtio'/>
|
||||||
|
</interface>
|
||||||
|
<interface type='user'>
|
||||||
|
<mac address='00:11:22:33:44:55'/>
|
||||||
|
<acpi index='300'/>
|
||||||
|
<model type='virtio'/>
|
||||||
|
</interface>
|
||||||
|
<input type='mouse' bus='ps2'/>
|
||||||
|
<input type='keyboard' bus='ps2'/>
|
||||||
|
<video>
|
||||||
|
<model type='cirrus' vram='16384' heads='1'/>
|
||||||
|
<acpi index='1729'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
|
||||||
|
</video>
|
||||||
|
<memballoon model='virtio'>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
|
||||||
|
</memballoon>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
@ -3611,6 +3611,8 @@ mymain(void)
|
|||||||
DO_TEST_CAPS_LATEST("virtio-9p-multidevs");
|
DO_TEST_CAPS_LATEST("virtio-9p-multidevs");
|
||||||
DO_TEST_CAPS_LATEST("virtio-9p-createmode");
|
DO_TEST_CAPS_LATEST("virtio-9p-createmode");
|
||||||
|
|
||||||
|
DO_TEST_CAPS_LATEST("devices-acpi-index");
|
||||||
|
|
||||||
if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
|
if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
|
||||||
virFileDeleteTree(fakerootdir);
|
virFileDeleteTree(fakerootdir);
|
||||||
|
|
||||||
|
@ -0,0 +1,73 @@
|
|||||||
|
<domain type='qemu'>
|
||||||
|
<name>fdr-br</name>
|
||||||
|
<uuid>3ec6cbe1-b5a2-4515-b800-31a61855df41</uuid>
|
||||||
|
<memory unit='KiB'>2097152</memory>
|
||||||
|
<currentMemory unit='KiB'>2097152</currentMemory>
|
||||||
|
<vcpu placement='static' cpuset='0-1'>2</vcpu>
|
||||||
|
<os>
|
||||||
|
<type arch='x86_64' machine='pc-i440fx-5.0'>hvm</type>
|
||||||
|
<boot dev='hd'/>
|
||||||
|
</os>
|
||||||
|
<features>
|
||||||
|
<acpi/>
|
||||||
|
<apic/>
|
||||||
|
<pae/>
|
||||||
|
</features>
|
||||||
|
<cpu mode='custom' match='exact' check='none'>
|
||||||
|
<model fallback='forbid'>qemu64</model>
|
||||||
|
</cpu>
|
||||||
|
<clock offset='utc'/>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>restart</on_crash>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/bin/qemu-system-x86_64</emulator>
|
||||||
|
<disk type='file' device='disk'>
|
||||||
|
<driver name='qemu' type='raw'/>
|
||||||
|
<source file='/var/lib/libvirt/images/test.img'/>
|
||||||
|
<target dev='vda' bus='virtio'/>
|
||||||
|
<acpi index='1'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
|
||||||
|
</disk>
|
||||||
|
<disk type='file' device='disk'>
|
||||||
|
<driver name='qemu' type='raw'/>
|
||||||
|
<source file='/var/lib/libvirt/images/test1.img'/>
|
||||||
|
<target dev='vdb' bus='virtio'/>
|
||||||
|
<acpi index='42'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
|
||||||
|
</disk>
|
||||||
|
<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'/>
|
||||||
|
<interface type='user'>
|
||||||
|
<mac address='00:11:22:33:44:55'/>
|
||||||
|
<model type='virtio'/>
|
||||||
|
<acpi index='100'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
|
||||||
|
</interface>
|
||||||
|
<interface type='user'>
|
||||||
|
<mac address='00:11:22:33:44:55'/>
|
||||||
|
<model type='virtio'/>
|
||||||
|
<acpi index='200'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
|
||||||
|
</interface>
|
||||||
|
<interface type='user'>
|
||||||
|
<mac address='00:11:22:33:44:55'/>
|
||||||
|
<model type='virtio'/>
|
||||||
|
<acpi index='300'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
|
||||||
|
</interface>
|
||||||
|
<input type='mouse' bus='ps2'/>
|
||||||
|
<input type='keyboard' bus='ps2'/>
|
||||||
|
<audio id='1' type='none'/>
|
||||||
|
<video>
|
||||||
|
<model type='cirrus' vram='16384' heads='1' primary='yes'/>
|
||||||
|
<acpi index='1729'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
|
||||||
|
</video>
|
||||||
|
<memballoon model='virtio'>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
|
||||||
|
</memballoon>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
@ -1522,6 +1522,8 @@ mymain(void)
|
|||||||
driver.config->nogfxAllowHostAudio = false;
|
driver.config->nogfxAllowHostAudio = false;
|
||||||
g_unsetenv("QEMU_AUDIO_DRV");
|
g_unsetenv("QEMU_AUDIO_DRV");
|
||||||
|
|
||||||
|
DO_TEST_CAPS_LATEST("devices-acpi-index");
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
|
if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
|
||||||
virFileDeleteTree(fakerootdir);
|
virFileDeleteTree(fakerootdir);
|
||||||
|
Loading…
Reference in New Issue
Block a user