[libvirt] [PATCH v2 2/2] conf: Add all controllers using virDomainControllerInsert()

Laine Stump laine at laine.org
Wed Sep 20 15:15:10 UTC 2017


On 09/07/2017 01:00 PM, Andrea Bolognani wrote:
> Doing so is smarter than just appending them, because it takes the
> controller index into account and will prevent problematic situations
> such as a PCI Bridge being listed before the PCI controller it's
> supposed to be plugged into, which QEMU can't cope with.
>
> Although the QEMU command line for affected guests will be altered,
> none of the changes should impact the guest ABI.

ACK as long as it doesn't mess up migration (I guess we need to find
some config that already works, but changes the ordering with the new
code, and make sure it can be migrated from old->new. Or we could assume
that 1) we believe it isn't a problem, and 2) in practice most things
that would be re-ordered wouldn't have worked at all without the
re-ordering, so it's a non-issue).

>
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1479674
>
> Signed-off-by: Andrea Bolognani <abologna at redhat.com>
> ---
>  src/conf/domain_conf.c                             |  2 +-
>  .../qemuxml2argv-channel-virtio-default.args       |  2 +-
>  .../qemuxml2argv-channel-virtio-unix.args          |  2 +-
>  .../qemuxml2argv-chardev-reconnect.args            |  2 +-
>  .../qemuxml2argv-pci-autoadd-idx.args              | 16 ++++++++--------
>  .../qemuxml2argv-pseries-many-buses-2.args         |  4 ++--
>  .../qemuxml2xmlout-aarch64-virtio-pci-default.xml  |  6 +++---
>  ...2xmlout-aarch64-virtio-pci-manual-addresses.xml |  6 +++---
>  .../qemuxml2xmlout-channel-virtio-auto.xml         |  2 +-
>  ...qemuxml2xmlout-hostdev-scsi-autogen-address.xml |  6 +++---
>  .../qemuxml2xmlout-pci-autoadd-idx.xml             | 22 +++++++++++-----------
>  .../qemuxml2xmlout-pseries-many-buses-2.xml        |  6 +++---
>  .../qemuxml2xmlout-pseries-phb-default-missing.xml |  8 ++++----
>  13 files changed, 42 insertions(+), 42 deletions(-)
>
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index b1b9d161c..388701680 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -16845,7 +16845,7 @@ virDomainDefAddController(virDomainDefPtr def, int type, int idx, int model)
>      cont->idx = idx;
>      cont->model = model;
>  
> -    if (VIR_APPEND_ELEMENT_COPY(def->controllers, def->ncontrollers, cont) < 0)
> +    if (virDomainControllerInsert(def, cont) < 0)
>          goto error;
>  
>      return cont;
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-default.args b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-default.args
> index 1d1501b39..4ebca6e06 100644
> --- a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-default.args
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-default.args
> @@ -19,8 +19,8 @@ server,nowait \
>  -mon chardev=charmonitor,id=monitor,mode=readline \
>  -no-acpi \
>  -boot c \
> --device virtio-serial-pci,id=virtio-serial1,bus=pci.0,addr=0xa \
>  -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x3 \
> +-device virtio-serial-pci,id=virtio-serial1,bus=pci.0,addr=0xa \
>  -usb \
>  -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
>  -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.args b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.args
> index 8e0452a9f..baed9c853 100644
> --- a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.args
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.args
> @@ -19,8 +19,8 @@ server,nowait \
>  -mon chardev=charmonitor,id=monitor,mode=readline \
>  -no-acpi \
>  -boot c \
> --device virtio-serial-pci,id=virtio-serial1,bus=pci.0,addr=0xa \
>  -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x3 \
> +-device virtio-serial-pci,id=virtio-serial1,bus=pci.0,addr=0xa \
>  -usb \
>  -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
>  -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect.args b/tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect.args
> index 8c6586e48..f4f35b07e 100644
> --- a/tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect.args
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect.args
> @@ -19,8 +19,8 @@ server,nowait \
>  -mon chardev=charmonitor,id=monitor,mode=readline \
>  -no-acpi \
>  -boot c \
> --device virtio-serial-pci,id=virtio-serial1,bus=pci.0,addr=0xa \
>  -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x3 \
> +-device virtio-serial-pci,id=virtio-serial1,bus=pci.0,addr=0xa \
>  -device usb-ccid,id=ccid0,bus=usb.0,port=1 \
>  -usb \
>  -chardev socket,id=charsmartcard0,path=/tmp/channel/asdf,reconnect=20 \
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pci-autoadd-idx.args b/tests/qemuxml2argvdata/qemuxml2argv-pci-autoadd-idx.args
> index 6b2f21bba..5e8c57bd5 100644
> --- a/tests/qemuxml2argvdata/qemuxml2argv-pci-autoadd-idx.args
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-pci-autoadd-idx.args
> @@ -17,14 +17,14 @@ QEMU_AUDIO_DRV=none \
>  server,nowait \
>  -mon chardev=charmonitor,id=monitor,mode=readline \
>  -boot c \
> --device pci-bridge,chassis_nr=8,id=pci.8,bus=pci.0,addr=0x3 \
> --device pci-bridge,chassis_nr=1,id=pci.1,bus=pci.0,addr=0x4 \
> --device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.0,addr=0x5 \
> --device pci-bridge,chassis_nr=3,id=pci.3,bus=pci.0,addr=0x6 \
> --device pci-bridge,chassis_nr=4,id=pci.4,bus=pci.0,addr=0x7 \
> --device pci-bridge,chassis_nr=5,id=pci.5,bus=pci.0,addr=0x8 \
> --device pci-bridge,chassis_nr=6,id=pci.6,bus=pci.0,addr=0x9 \
> --device pci-bridge,chassis_nr=7,id=pci.7,bus=pci.0,addr=0xa \
> +-device pci-bridge,chassis_nr=1,id=pci.1,bus=pci.0,addr=0x3 \
> +-device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.0,addr=0x4 \
> +-device pci-bridge,chassis_nr=3,id=pci.3,bus=pci.0,addr=0x5 \
> +-device pci-bridge,chassis_nr=4,id=pci.4,bus=pci.0,addr=0x6 \
> +-device pci-bridge,chassis_nr=5,id=pci.5,bus=pci.0,addr=0x7 \
> +-device pci-bridge,chassis_nr=6,id=pci.6,bus=pci.0,addr=0x8 \
> +-device pci-bridge,chassis_nr=7,id=pci.7,bus=pci.0,addr=0x9 \
> +-device pci-bridge,chassis_nr=8,id=pci.8,bus=pci.0,addr=0xa \
>  -usb \
>  -drive file=/var/iso/f18kde.iso,format=raw,if=none,media=cdrom,\
>  id=drive-ide0-1-0,readonly=on \
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-many-buses-2.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-many-buses-2.args
> index 13fed02f8..1a78db45f 100644
> --- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-many-buses-2.args
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-many-buses-2.args
> @@ -18,5 +18,5 @@ QEMU_AUDIO_DRV=none \
>  server,nowait \
>  -mon chardev=charmonitor,id=monitor,mode=readline \
>  -boot c \
> --device spapr-pci-host-bridge,index=1,id=pci.2 \
> --device spapr-pci-host-bridge,index=2,id=pci.1
> +-device spapr-pci-host-bridge,index=1,id=pci.1 \
> +-device spapr-pci-host-bridge,index=2,id=pci.2
> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-default.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-default.xml
> index e5496424b..3c0b71dde 100644
> --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-default.xml
> +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-default.xml
> @@ -32,9 +32,6 @@
>        <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
>      </disk>
>      <controller type='pci' index='0' model='pcie-root'/>
> -    <controller type='virtio-serial' index='0'>
> -      <address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
> -    </controller>
>      <controller type='pci' index='1' model='pcie-root-port'>
>        <model name='ioh3420'/>
>        <target chassis='1' port='0x8'/>
> @@ -65,6 +62,9 @@
>        <target chassis='6' port='0xd'/>
>        <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x5'/>
>      </controller>
> +    <controller type='virtio-serial' index='0'>
> +      <address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
> +    </controller>
>      <interface type='user'>
>        <mac address='52:54:00:09:a4:37'/>
>        <model type='virtio'/>
> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-addresses.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-addresses.xml
> index 83d8dcc4a..ee9ec022c 100644
> --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-addresses.xml
> +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-addresses.xml
> @@ -41,14 +41,14 @@
>        <target chassisNr='2'/>
>        <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
>      </controller>
> -    <controller type='scsi' index='0' model='virtio-scsi'>
> -      <address type='pci' domain='0x0000' bus='0x03' slot='0x01' function='0x0'/>
> -    </controller>
>      <controller type='pci' index='3' model='pci-bridge'>
>        <model name='pci-bridge'/>
>        <target chassisNr='3'/>
>        <address type='pci' domain='0x0000' bus='0x01' slot='0x01' function='0x0'/>
>      </controller>
> +    <controller type='scsi' index='0' model='virtio-scsi'>
> +      <address type='pci' domain='0x0000' bus='0x03' slot='0x01' function='0x0'/>
> +    </controller>
>      <interface type='user'>
>        <mac address='52:54:00:09:a4:37'/>
>        <model type='virtio'/>
> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-auto.xml
> index 6fd035815..c2c07732b 100644
> --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-auto.xml
> +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-auto.xml
> @@ -31,10 +31,10 @@
>      <controller type='virtio-serial' index='1'>
>        <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
>      </controller>
> -    <controller type='pci' index='0' model='pci-root'/>
>      <controller type='virtio-serial' index='2'>
>        <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
>      </controller>
> +    <controller type='pci' index='0' model='pci-root'/>
>      <channel type='pty'>
>        <target type='virtio' name='org.linux-kvm.port.0'/>
>        <address type='virtio-serial' controller='0' bus='0' port='1'/>
> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-autogen-address.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-autogen-address.xml
> index 8e93056ee..998cbb5aa 100644
> --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-autogen-address.xml
> +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-autogen-address.xml
> @@ -22,6 +22,9 @@
>      <controller type='scsi' index='0' model='virtio-scsi'>
>        <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
>      </controller>
> +    <controller type='scsi' index='1'>
> +      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
> +    </controller>
>      <controller type='usb' index='0'>
>        <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
>      </controller>
> @@ -29,9 +32,6 @@
>        <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
>      </controller>
>      <controller type='pci' index='0' model='pci-root'/>
> -    <controller type='scsi' index='1'>
> -      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
> -    </controller>
>      <input type='mouse' bus='ps2'/>
>      <input type='keyboard' bus='ps2'/>
>      <hostdev mode='subsystem' type='scsi' managed='yes'>
> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pci-autoadd-idx.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pci-autoadd-idx.xml
> index c6437391c..f44398d6c 100644
> --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pci-autoadd-idx.xml
> +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pci-autoadd-idx.xml
> @@ -32,45 +32,45 @@
>      <controller type='ide' index='0'>
>        <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
>      </controller>
> -    <controller type='pci' index='8' model='pci-bridge'>
> -      <model name='pci-bridge'/>
> -      <target chassisNr='8'/>
> -      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
> -    </controller>
>      <controller type='pci' index='0' model='pci-root'/>
>      <controller type='pci' index='1' model='pci-bridge'>
>        <model name='pci-bridge'/>
>        <target chassisNr='1'/>
> -      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
> +      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
>      </controller>
>      <controller type='pci' index='2' model='pci-bridge'>
>        <model name='pci-bridge'/>
>        <target chassisNr='2'/>
> -      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
> +      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
>      </controller>
>      <controller type='pci' index='3' model='pci-bridge'>
>        <model name='pci-bridge'/>
>        <target chassisNr='3'/>
> -      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
> +      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
>      </controller>
>      <controller type='pci' index='4' model='pci-bridge'>
>        <model name='pci-bridge'/>
>        <target chassisNr='4'/>
> -      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
> +      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
>      </controller>
>      <controller type='pci' index='5' model='pci-bridge'>
>        <model name='pci-bridge'/>
>        <target chassisNr='5'/>
> -      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
> +      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
>      </controller>
>      <controller type='pci' index='6' model='pci-bridge'>
>        <model name='pci-bridge'/>
>        <target chassisNr='6'/>
> -      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
> +      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
>      </controller>
>      <controller type='pci' index='7' model='pci-bridge'>
>        <model name='pci-bridge'/>
>        <target chassisNr='7'/>
> +      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
> +    </controller>
> +    <controller type='pci' index='8' model='pci-bridge'>
> +      <model name='pci-bridge'/>
> +      <target chassisNr='8'/>
>        <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
>      </controller>
>      <input type='mouse' bus='ps2'/>
> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-many-buses-2.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-many-buses-2.xml
> index 14f3e3624..7e0bb2053 100644
> --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-many-buses-2.xml
> +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-many-buses-2.xml
> @@ -18,15 +18,15 @@
>        <model name='spapr-pci-host-bridge'/>
>        <target index='0'/>
>      </controller>
> -    <controller type='pci' index='2' model='pci-root'>
> +    <controller type='pci' index='1' model='pci-root'>
>        <model name='spapr-pci-host-bridge'/>
>        <target index='1'/>
>      </controller>
> -    <controller type='usb' index='0' model='none'/>
> -    <controller type='pci' index='1' model='pci-root'>
> +    <controller type='pci' index='2' model='pci-root'>
>        <model name='spapr-pci-host-bridge'/>
>        <target index='2'/>
>      </controller>
> +    <controller type='usb' index='0' model='none'/>
>      <memballoon model='none'/>
>      <panic model='pseries'/>
>    </devices>
> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-phb-default-missing.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-phb-default-missing.xml
> index 62708b4a4..2c1e64e88 100644
> --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-phb-default-missing.xml
> +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-phb-default-missing.xml
> @@ -14,6 +14,10 @@
>    <on_crash>destroy</on_crash>
>    <devices>
>      <emulator>/usr/bin/qemu-system-ppc64</emulator>
> +    <controller type='pci' index='0' model='pci-root'>
> +      <model name='spapr-pci-host-bridge'/>
> +      <target index='0'/>
> +    </controller>
>      <controller type='pci' index='1' model='pci-root'>
>        <model name='spapr-pci-host-bridge'/>
>        <target index='1'/>
> @@ -23,10 +27,6 @@
>        <target index='2'/>
>      </controller>
>      <controller type='usb' index='0' model='none'/>
> -    <controller type='pci' index='0' model='pci-root'>
> -      <model name='spapr-pci-host-bridge'/>
> -      <target index='0'/>
> -    </controller>
>      <memballoon model='none'/>
>      <panic model='pseries'/>
>    </devices>





More information about the libvir-list mailing list