def->serials[i]->target.port);
+ return -1;
+ }
+ used_serial_port[def->serials[i]->target.port] = true;
+ }
+
+ }
+
+ /* Assign the ports to the devices. */
+ for (i = 0; i < isa_serial_count; i++) {
+ int isa_index = isa_device_index_arr[i];
+ if (def->serials[isa_index]->target.port != -1)
+ continue;
+ for (j = 0; j < VIR_MAX_AVAILABLE_ISA_SERIAL_PORTS; j++) {
+ if (!used_serial_port[j]) {
+ def->serials[isa_index]->target.port = j;
+ used_serial_port[j] = true;
+ break;
+ }
+ }
+ if (def->serials[isa_index]->target.port == -1) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("out of ports for isa-serial device."));
+ return -1;
+ }
+ }
+ return 0;
+}
+
static void
virDomainChrDefPostParse(virDomainChrDef *chr,
const virDomainDef *def)
@@ -6186,6 +6241,9 @@ virDomainDefPostParse(virDomainDef *def,
goto cleanup;
}
+ if (virDomainChrIsaSerialDefPostParse(def) < 0)
+ return -1;
+
/* iterate the devices */
ret = virDomainDeviceInfoIterateFlags(def,
virDomainDefPostParseDeviceIterator,
@@ -19857,14 +19915,6 @@ virDomainDefParseXML(xmlXPathContextPtr ctxt,
if (!chr)
return NULL;
- if (chr->target.port == -1) {
- int maxport = -1;
- for (j = 0; j < i; j++) {
- if (def->serials[j]->target.port > maxport)
- maxport = def->serials[j]->target.port;
- }
- chr->target.port = maxport + 1;
- }
def->serials[def->nserials++] = chr;
}
VIR_FREE(nodes);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index c0c07ea6ba..be162e592c 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1179,6 +1179,7 @@ typedef enum {
VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST
} virDomainChrConsoleTargetType;
+#define VIR_MAX_AVAILABLE_ISA_SERIAL_PORTS 4
typedef enum {
VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE = 0,
VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL,
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index c47998aabd..797cdfb955 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -10953,11 +10953,22 @@ qemuBuildSerialChrDeviceProps(const virDomainDef
*def,
return NULL;
}
- if (virJSONValueObjectAdd(&props,
- "s:driver",
virDomainChrSerialTargetModelTypeToString(serial->targetModel),
- "s:chardev", chardev,
- "s:id", serial->info.alias,
- NULL) < 0)
+ if (serial->targetModel ==
VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL) {
+ if (virJSONValueObjectAdd(&props,
+ "s:driver",
+
virDomainChrSerialTargetModelTypeToString(serial->targetModel),
+ "s:chardev", chardev,
+ "s:id", serial->info.alias,
+ "k:index", serial->target.port,
+ NULL) < 0)
+ return NULL;
+ }
+ else if (virJSONValueObjectAdd(&props,
+ "s:driver",
+
virDomainChrSerialTargetModelTypeToString(serial->targetModel),
+ "s:chardev", chardev,
+ "s:id", serial->info.alias,
+ NULL) < 0)
return NULL;
if (qemuBuildDeviceAddressProps(props, def, &serial->info) < 0)
diff --git
a/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live+console-virtio.xml
b/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live+console-virtio.xml
index 5d688e7748..295d75b768 100644
---
a/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live+console-virtio.xml
+++
b/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live+console-virtio.xml
@@ -74,7 +74,7 @@
<alias name='serial0'/>
</serial>
<serial type='pty'>
- <target type='isa-serial' port='0'>
+ <target type='isa-serial' port='1'>
<model name='isa-serial'/>
</target>
<alias name='serial1'/>
@@ -82,7 +82,7 @@
<serial type='tcp'>
<source mode='bind' host='0.0.0.0' service='2445'/>
<protocol type='raw'/>
- <target type='isa-serial' port='1'>
+ <target type='isa-serial' port='2'>
<model name='isa-serial'/>
</target>
<alias name='serial2'/>
diff --git
a/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live.xml
b/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live.xml
index b916f30412..850ebddf52 100644
--- a/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live.xml
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-console-compat-2-live.xml
@@ -74,7 +74,7 @@
<alias name='serial0'/>
</serial>
<serial type='pty'>
- <target type='isa-serial' port='0'>
+ <target type='isa-serial' port='1'>
<model name='isa-serial'/>
</target>
<alias name='serial1'/>
@@ -82,7 +82,7 @@
<serial type='tcp'>
<source mode='bind' host='0.0.0.0' service='2445'/>
<protocol type='raw'/>
- <target type='isa-serial' port='1'>
+ <target type='isa-serial' port='2'>
<model name='isa-serial'/>
</target>
<alias name='serial2'/>
diff --git a/tests/qemuxml2argvdata/bios.args
b/tests/qemuxml2argvdata/bios.args
index 0469b7419e..62ec87541d 100644
--- a/tests/qemuxml2argvdata/bios.args
+++ b/tests/qemuxml2argvdata/bios.args
@@ -31,7 +31,7 @@ QEMU_AUDIO_DRV=none \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device
ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev pty,id=charserial0 \
--device isa-serial,chardev=charserial0,id=serial0 \
+-device isa-serial,chardev=charserial0,id=serial0,index=0 \
-device usb-tablet,id=input0,bus=usb.0,port=1 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/console-compat-auto.args
b/tests/qemuxml2argvdata/console-compat-auto.args
index 5285d0749a..9c459b641b 100644
--- a/tests/qemuxml2argvdata/console-compat-auto.args
+++ b/tests/qemuxml2argvdata/console-compat-auto.args
@@ -30,6 +30,6 @@ QEMU_AUDIO_DRV=none \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device
ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev pty,id=charserial0 \
--device isa-serial,chardev=charserial0,id=serial0 \
+-device isa-serial,chardev=charserial0,id=serial0,index=0 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/console-compat-chardev.args
b/tests/qemuxml2argvdata/console-compat-chardev.args
index 5285d0749a..9c459b641b 100644
--- a/tests/qemuxml2argvdata/console-compat-chardev.args
+++ b/tests/qemuxml2argvdata/console-compat-chardev.args
@@ -30,6 +30,6 @@ QEMU_AUDIO_DRV=none \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device
ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev pty,id=charserial0 \
--device isa-serial,chardev=charserial0,id=serial0 \
+-device isa-serial,chardev=charserial0,id=serial0,index=0 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/console-compat.args
b/tests/qemuxml2argvdata/console-compat.args
index 9f37788586..709a82faad 100644
--- a/tests/qemuxml2argvdata/console-compat.args
+++ b/tests/qemuxml2argvdata/console-compat.args
@@ -30,5 +30,5 @@ QEMU_AUDIO_DRV=none \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device
ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev pty,id=charserial0 \
--device isa-serial,chardev=charserial0,id=serial0 \
+-device isa-serial,chardev=charserial0,id=serial0,index=0 \
-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/console-virtio-many.args
b/tests/qemuxml2argvdata/console-virtio-many.args
index dc1aca1129..b509cd55b5 100644
--- a/tests/qemuxml2argvdata/console-virtio-many.args
+++ b/tests/qemuxml2argvdata/console-virtio-many.args
@@ -31,7 +31,7 @@ QEMU_AUDIO_DRV=none \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device
ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev pty,id=charserial0 \
--device isa-serial,chardev=charserial0,id=serial0 \
+-device isa-serial,chardev=charserial0,id=serial0,index=0 \
-chardev pty,id=charconsole1 \
-device virtconsole,chardev=charconsole1,id=console1 \
-chardev pty,id=charconsole2 \
diff --git a/tests/qemuxml2argvdata/controller-order.args
b/tests/qemuxml2argvdata/controller-order.args
index 51571a27bf..51fa04dfd8 100644
--- a/tests/qemuxml2argvdata/controller-order.args
+++ b/tests/qemuxml2argvdata/controller-order.args
@@ -37,7 +37,7 @@ QEMU_AUDIO_DRV=spice \
-chardev spicevmc,id=charsmartcard0,name=smartcard \
-device
ccid-card-passthru,chardev=charsmartcard0,id=smartcard0,bus=ccid0.0 \
-chardev pty,id=charserial0 \
--device isa-serial,chardev=charserial0,id=serial0 \
+-device isa-serial,chardev=charserial0,id=serial0,index=0 \
-chardev spicevmc,id=charchannel0,name=vdagent \
-device
virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=com.redhat.spice.0
\
-device usb-tablet,id=input0,bus=usb.0,port=1.2 \
diff --git a/tests/qemuxml2argvdata/name-escape.x86_64-2.11.0.args
b/tests/qemuxml2argvdata/name-escape.x86_64-2.11.0.args
index 1ce91ff354..a57adedfa5 100644
--- a/tests/qemuxml2argvdata/name-escape.x86_64-2.11.0.args
+++ b/tests/qemuxml2argvdata/name-escape.x86_64-2.11.0.args
@@ -32,9 +32,9 @@ QEMU_AUDIO_DRV=spice \
-device
ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1,write-cache=on
\
-device
ccid-card-emulated,backend=certificates,cert1=cert1,,foo,cert2=cert2,cert3=cert3,db=/etc/pki/nssdb,,foo,id=smartcard0,bus=ccid0.0
\
-chardev tty,id=charserial0,path=/dev/ttyS2,,foo \
--device isa-serial,chardev=charserial0,id=serial0 \
+-device isa-serial,chardev=charserial0,id=serial0,index=1 \
-chardev file,id=charserial1,path=/tmp/serial.log,,foo,append=on \
--device isa-serial,chardev=charserial1,id=serial1 \
+-device isa-serial,chardev=charserial1,id=serial1,index=0 \
-chardev pipe,id=charchannel0,path=/tmp/guestfwd,,foo \
-netdev user,guestfwd=tcp:10.0.2.1:4600-chardev:charchannel0,id=channel0 \
-vnc vnc=unix:/tmp/lib/domain--1-foo=1,,bar=2/vnc.sock \
diff --git a/tests/qemuxml2argvdata/q35-virt-manager-basic.args
b/tests/qemuxml2argvdata/q35-virt-manager-basic.args
index 6e84c9ca2a..a33a74e355 100644
--- a/tests/qemuxml2argvdata/q35-virt-manager-basic.args
+++ b/tests/qemuxml2argvdata/q35-virt-manager-basic.args
@@ -40,7 +40,7 @@ QEMU_AUDIO_DRV=spice \
-netdev user,id=hostnet0 \
-device
virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:9a:e6:c6,bus=pci.1,addr=0x0
\
-chardev pty,id=charserial0 \
--device isa-serial,chardev=charserial0,id=serial0 \
+-device isa-serial,chardev=charserial0,id=serial0,index=0 \
-chardev
socket,id=charchannel0,path=/tmp/channel/domain--1-virt-manager-basic/org.qemu.guest_agent.0,server=on,wait=off
\
-device
virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=org.qemu.guest_agent.0
\
-chardev spicevmc,id=charchannel1,name=vdagent \
diff --git a/tests/qemuxml2argvdata/serial-dev-chardev-iobase.args
b/tests/qemuxml2argvdata/serial-dev-chardev-iobase.args
index dfa6785795..1f358b6469 100644
--- a/tests/qemuxml2argvdata/serial-dev-chardev-iobase.args
+++ b/tests/qemuxml2argvdata/serial-dev-chardev-iobase.args
@@ -30,6 +30,6 @@ QEMU_AUDIO_DRV=none \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device
ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev tty,id=charserial0,path=/dev/ttyS2 \
--device isa-serial,chardev=charserial0,id=serial0,iobase=1016,irq=4 \
+-device isa-serial,chardev=charserial0,id=serial0,index=0,iobase=1016,irq=4
\
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/serial-dev-chardev.args
b/tests/qemuxml2argvdata/serial-dev-chardev.args
index c325f21e0c..47da5b8454 100644
--- a/tests/qemuxml2argvdata/serial-dev-chardev.args
+++ b/tests/qemuxml2argvdata/serial-dev-chardev.args
@@ -30,6 +30,6 @@ QEMU_AUDIO_DRV=none \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device
ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev tty,id=charserial0,path=/dev/ttyS2 \
--device isa-serial,chardev=charserial0,id=serial0 \
+-device isa-serial,chardev=charserial0,id=serial0,index=0 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/serial-file-chardev.args
b/tests/qemuxml2argvdata/serial-file-chardev.args
index 4cbd0edf1c..5b8f3be45a 100644
--- a/tests/qemuxml2argvdata/serial-file-chardev.args
+++ b/tests/qemuxml2argvdata/serial-file-chardev.args
@@ -30,6 +30,6 @@ QEMU_AUDIO_DRV=none \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device
ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev file,id=charserial0,path=/tmp/serial.log,append=on \
--device isa-serial,chardev=charserial0,id=serial0 \
+-device isa-serial,chardev=charserial0,id=serial0,index=0 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/serial-file-log.args
b/tests/qemuxml2argvdata/serial-file-log.args
index c4c6106200..9ee066ef49 100644
--- a/tests/qemuxml2argvdata/serial-file-log.args
+++ b/tests/qemuxml2argvdata/serial-file-log.args
@@ -30,5 +30,5 @@ QEMU_AUDIO_DRV=none \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device
ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev
file,id=charserial0,path=/tmp/serial.log,logfile=/var/lib/libvirt/qemu/demo-serial.log,logappend=off
\
--device isa-serial,chardev=charserial0,id=serial0 \
+-device isa-serial,chardev=charserial0,id=serial0,index=0 \
-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/serial-many-chardev.args
b/tests/qemuxml2argvdata/serial-many-chardev.args
index 2c548c9e4b..da0d0b21c3 100644
--- a/tests/qemuxml2argvdata/serial-many-chardev.args
+++ b/tests/qemuxml2argvdata/serial-many-chardev.args
@@ -30,8 +30,8 @@ QEMU_AUDIO_DRV=none \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device
ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev pty,id=charserial0 \
--device isa-serial,chardev=charserial0,id=serial0 \
+-device isa-serial,chardev=charserial0,id=serial0,index=0 \
-chardev file,id=charserial1,path=/tmp/serial.log \
--device isa-serial,chardev=charserial1,id=serial1 \
+-device isa-serial,chardev=charserial1,id=serial1,index=1 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/serial-pty-chardev.args
b/tests/qemuxml2argvdata/serial-pty-chardev.args
index 5285d0749a..9c459b641b 100644
--- a/tests/qemuxml2argvdata/serial-pty-chardev.args
+++ b/tests/qemuxml2argvdata/serial-pty-chardev.args
@@ -30,6 +30,6 @@ QEMU_AUDIO_DRV=none \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device
ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev pty,id=charserial0 \
--device isa-serial,chardev=charserial0,id=serial0 \
+-device isa-serial,chardev=charserial0,id=serial0,index=0 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/serial-spiceport.args
b/tests/qemuxml2argvdata/serial-spiceport.args
index 43e65a0679..704e6d1820 100644
--- a/tests/qemuxml2argvdata/serial-spiceport.args
+++ b/tests/qemuxml2argvdata/serial-spiceport.args
@@ -29,7 +29,7 @@ QEMU_AUDIO_DRV=spice \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device
ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev spiceport,id=charserial0,name=org.qemu.console.serial.0 \
--device isa-serial,chardev=charserial0,id=serial0 \
+-device isa-serial,chardev=charserial0,id=serial0,index=0 \
-device usb-tablet,id=input0,bus=usb.0,port=1 \
-spice
port=5903,tls-port=5904,addr=127.0.0.1,x509-dir=/etc/pki/libvirt-spice,seamless-migration=on
\
-device
qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0,addr=0x2 \
diff --git a/tests/qemuxml2argvdata/serial-tcp-chardev.args
b/tests/qemuxml2argvdata/serial-tcp-chardev.args
index aec7093d03..263add4409 100644
--- a/tests/qemuxml2argvdata/serial-tcp-chardev.args
+++ b/tests/qemuxml2argvdata/serial-tcp-chardev.args
@@ -30,6 +30,6 @@ QEMU_AUDIO_DRV=none \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device
ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev socket,id=charserial0,host=127.0.0.1,port=9999 \
--device isa-serial,chardev=charserial0,id=serial0 \
+-device isa-serial,chardev=charserial0,id=serial0,index=0 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/serial-tcp-telnet-chardev.args
b/tests/qemuxml2argvdata/serial-tcp-telnet-chardev.args
index 72f81d7938..13e092c4c7 100644
--- a/tests/qemuxml2argvdata/serial-tcp-telnet-chardev.args
+++ b/tests/qemuxml2argvdata/serial-tcp-telnet-chardev.args
@@ -30,6 +30,6 @@ QEMU_AUDIO_DRV=none \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device
ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev
socket,id=charserial0,host=127.0.0.1,port=9999,telnet=on,server=on,wait=off
\
--device isa-serial,chardev=charserial0,id=serial0 \
+-device isa-serial,chardev=charserial0,id=serial0,index=0 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/serial-tcp-tlsx509-chardev-notls.args
b/tests/qemuxml2argvdata/serial-tcp-tlsx509-chardev-notls.args
index 7db40862e9..8bf070d820 100644
--- a/tests/qemuxml2argvdata/serial-tcp-tlsx509-chardev-notls.args
+++ b/tests/qemuxml2argvdata/serial-tcp-tlsx509-chardev-notls.args
@@ -30,8 +30,8 @@ QEMU_AUDIO_DRV=none \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device
ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev
udp,id=charserial0,host=127.0.0.1,port=2222,localaddr=127.0.0.1,localport=1111
\
--device isa-serial,chardev=charserial0,id=serial0 \
+-device isa-serial,chardev=charserial0,id=serial0,index=0 \
-chardev socket,id=charserial1,host=127.0.0.1,port=5555 \
--device isa-serial,chardev=charserial1,id=serial1 \
+-device isa-serial,chardev=charserial1,id=serial1,index=1 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \
-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/serial-tcp-tlsx509-chardev-notls.xml
b/tests/qemuxml2argvdata/serial-tcp-tlsx509-chardev-notls.xml
index 9b0b8b3e73..522f0184d3 100644
--- a/tests/qemuxml2argvdata/serial-tcp-tlsx509-chardev-notls.xml
+++ b/tests/qemuxml2argvdata/serial-tcp-tlsx509-chardev-notls.xml
@@ -37,7 +37,7 @@
<serial type='tcp'>
<source mode='connect' host='127.0.0.1' service='5555' tls='no'/>
<protocol type='raw'/>
- <target type='isa-serial' port='0'>
+ <target type='isa-serial' port='1'>
<model name='isa-serial'/>
</target>
</serial>
diff --git a/tests/qemuxml2argvdata/serial-tcp-tlsx509-chardev-verify.args
b/tests/qemuxml2argvdata/serial-tcp-tlsx509-chardev-verify.args
index f3dc5f5019..374d24ec00 100644
--- a/tests/qemuxml2argvdata/serial-tcp-tlsx509-chardev-verify.args
+++ b/tests/qemuxml2argvdata/serial-tcp-tlsx509-chardev-verify.args
@@ -30,9 +30,9 @@ QEMU_AUDIO_DRV=none \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device
ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev
udp,id=charserial0,host=127.0.0.1,port=2222,localaddr=127.0.0.1,localport=1111
\
--device isa-serial,chardev=charserial0,id=serial0 \
+-device isa-serial,chardev=charserial0,id=serial0,index=0 \
-object
tls-creds-x509,id=objcharserial1_tls0,dir=/etc/pki/libvirt-chardev,endpoint=client,verify-peer=on
\
-chardev
socket,id=charserial1,host=127.0.0.1,port=5555,tls-creds=objcharserial1_tls0
\
--device isa-serial,chardev=charserial1,id=serial1 \
+-device isa-serial,chardev=charserial1,id=serial1,index=1 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/serial-tcp-tlsx509-chardev-verify.xml
b/tests/qemuxml2argvdata/serial-tcp-tlsx509-chardev-verify.xml
index 75c6c7f5f4..d41f5ee03e 100644
--- a/tests/qemuxml2argvdata/serial-tcp-tlsx509-chardev-verify.xml
+++ b/tests/qemuxml2argvdata/serial-tcp-tlsx509-chardev-verify.xml
@@ -29,7 +29,7 @@
<serial type='tcp'>
<source mode='connect' host='127.0.0.1' service='5555'/>
<protocol type='raw'/>
- <target port='0'/>
+ <target port='1'/>
</serial>
<console type='udp'>
<source mode='bind' host='127.0.0.1' service='1111'/>
diff --git a/tests/qemuxml2argvdata/serial-tcp-tlsx509-chardev.args
b/tests/qemuxml2argvdata/serial-tcp-tlsx509-chardev.args
index f3dc5f5019..374d24ec00 100644
--- a/tests/qemuxml2argvdata/serial-tcp-tlsx509-chardev.args
+++ b/tests/qemuxml2argvdata/serial-tcp-tlsx509-chardev.args
@@ -30,9 +30,9 @@ QEMU_AUDIO_DRV=none \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device
ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev
udp,id=charserial0,host=127.0.0.1,port=2222,localaddr=127.0.0.1,localport=1111
\
--device isa-serial,chardev=charserial0,id=serial0 \
+-device isa-serial,chardev=charserial0,id=serial0,index=0 \
-object
tls-creds-x509,id=objcharserial1_tls0,dir=/etc/pki/libvirt-chardev,endpoint=client,verify-peer=on
\
-chardev
socket,id=charserial1,host=127.0.0.1,port=5555,tls-creds=objcharserial1_tls0
\
--device isa-serial,chardev=charserial1,id=serial1 \
+-device isa-serial,chardev=charserial1,id=serial1,index=1 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/serial-tcp-tlsx509-chardev.xml
b/tests/qemuxml2argvdata/serial-tcp-tlsx509-chardev.xml
index 75c6c7f5f4..d41f5ee03e 100644
--- a/tests/qemuxml2argvdata/serial-tcp-tlsx509-chardev.xml
+++ b/tests/qemuxml2argvdata/serial-tcp-tlsx509-chardev.xml
@@ -29,7 +29,7 @@
<serial type='tcp'>
<source mode='connect' host='127.0.0.1' service='5555'/>
<protocol type='raw'/>
- <target port='0'/>
+ <target port='1'/>
</serial>
<console type='udp'>
<source mode='bind' host='127.0.0.1' service='1111'/>
diff --git a/tests/qemuxml2argvdata/serial-tcp-tlsx509-secret-chardev.args
b/tests/qemuxml2argvdata/serial-tcp-tlsx509-secret-chardev.args
index 151629458b..2defeb28da 100644
--- a/tests/qemuxml2argvdata/serial-tcp-tlsx509-secret-chardev.args
+++ b/tests/qemuxml2argvdata/serial-tcp-tlsx509-secret-chardev.args
@@ -30,10 +30,10 @@ QEMU_AUDIO_DRV=none \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device
ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev
udp,id=charserial0,host=127.0.0.1,port=2222,localaddr=127.0.0.1,localport=1111
\
--device isa-serial,chardev=charserial0,id=serial0 \
+-device isa-serial,chardev=charserial0,id=serial0,index=0 \
-object
secret,id=charserial1-secret0,data=9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64
\
-object
tls-creds-x509,id=objcharserial1_tls0,dir=/etc/pki/libvirt-chardev,endpoint=client,verify-peer=on,passwordid=charserial1-secret0
\
-chardev
socket,id=charserial1,host=127.0.0.1,port=5555,tls-creds=objcharserial1_tls0
\
--device isa-serial,chardev=charserial1,id=serial1 \
+-device isa-serial,chardev=charserial1,id=serial1,index=1 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \
-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/serial-tcp-tlsx509-secret-chardev.xml
b/tests/qemuxml2argvdata/serial-tcp-tlsx509-secret-chardev.xml
index 670f282b84..2bf954bc9f 100644
--- a/tests/qemuxml2argvdata/serial-tcp-tlsx509-secret-chardev.xml
+++ b/tests/qemuxml2argvdata/serial-tcp-tlsx509-secret-chardev.xml
@@ -34,7 +34,7 @@
<serial type='tcp'>
<source mode='connect' host='127.0.0.1' service='5555'/>
<protocol type='raw'/>
- <target port='0'/>
+ <target port='1'/>
</serial>
<console type='udp'>
<source mode='bind' host='127.0.0.1' service='1111'/>
diff --git a/tests/qemuxml2argvdata/serial-udp-chardev.args
b/tests/qemuxml2argvdata/serial-udp-chardev.args
index 9d2f2e03e9..de6621f0e2 100644
--- a/tests/qemuxml2argvdata/serial-udp-chardev.args
+++ b/tests/qemuxml2argvdata/serial-udp-chardev.args
@@ -30,8 +30,8 @@ QEMU_AUDIO_DRV=none \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device
ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev
udp,id=charserial0,host=127.0.0.1,port=9998,localaddr=127.0.0.1,localport=9999
\
--device isa-serial,chardev=charserial0,id=serial0 \
+-device isa-serial,chardev=charserial0,id=serial0,index=0 \
-chardev udp,id=charserial1,host=,port=9999,localaddr=,localport=0 \
--device isa-serial,chardev=charserial1,id=serial1 \
+-device isa-serial,chardev=charserial1,id=serial1,index=1 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/serial-unix-chardev.args
b/tests/qemuxml2argvdata/serial-unix-chardev.args
index 19731b02b2..1e2444f824 100644
--- a/tests/qemuxml2argvdata/serial-unix-chardev.args
+++ b/tests/qemuxml2argvdata/serial-unix-chardev.args
@@ -28,8 +28,8 @@ QEMU_AUDIO_DRV=none \
-boot strict=on \
-usb \
-chardev socket,id=charserial0,path=/tmp/serial.sock \
--device isa-serial,chardev=charserial0,id=serial0 \
+-device isa-serial,chardev=charserial0,id=serial0,index=0 \
-chardev
socket,id=charserial1,path=/tmp/serial-server.sock,server=on,wait=off \
--device isa-serial,chardev=charserial1,id=serial1 \
+-device isa-serial,chardev=charserial1,id=serial1,index=1 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/serial-unix-chardev.x86_64-latest.args
b/tests/qemuxml2argvdata/serial-unix-chardev.x86_64-latest.args
index 1e3d5772b4..1387fc9a1d 100644
--- a/tests/qemuxml2argvdata/serial-unix-chardev.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/serial-unix-chardev.x86_64-latest.args
@@ -29,9 +29,9 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
-boot strict=on \
-device
'{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}' \
-chardev socket,id=charserial0,path=/tmp/serial.sock \
--device '{"driver":"isa-serial","chardev":"charserial0","id":"serial0"}' \
+-device
'{"driver":"isa-serial","chardev":"charserial0","id":"serial0","index":0}' \
-chardev socket,id=charserial1,fd=1729,server=on,wait=off \
--device '{"driver":"isa-serial","chardev":"charserial1","id":"serial1"}' \
+-device
'{"driver":"isa-serial","chardev":"charserial1","id":"serial1","index":1}' \
-audiodev '{"id":"audio1","driver":"none"}' \
-device
'{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","addr":"0x2"}'
\
-sandbox
on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
diff --git a/tests/qemuxml2argvdata/serial-vc-chardev.args
b/tests/qemuxml2argvdata/serial-vc-chardev.args
index d28a3eee47..09b33a15ee 100644
--- a/tests/qemuxml2argvdata/serial-vc-chardev.args
+++ b/tests/qemuxml2argvdata/serial-vc-chardev.args
@@ -30,6 +30,6 @@ QEMU_AUDIO_DRV=none \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device
ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-chardev vc,id=charserial0 \
--device isa-serial,chardev=charserial0,id=serial0 \
+-device isa-serial,chardev=charserial0,id=serial0,index=0 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/user-aliases.args
b/tests/qemuxml2argvdata/user-aliases.args
index 486473a566..8608144b5e 100644
--- a/tests/qemuxml2argvdata/user-aliases.args
+++ b/tests/qemuxml2argvdata/user-aliases.args
@@ -55,9 +55,9 @@ QEMU_AUDIO_DRV=none \
-device
rtl8139,netdev=hostua-AndAlsoClientMode,id=ua-AndAlsoClientMode,mac=52:54:00:8c:b1:f8,bus=pci.0,addr=0xa
\
-device
ccid-card-emulated,backend=nss-emulated,id=smartcard0,bus=ua-myCCID.0 \
-chardev pty,id=charserial0 \
--device isa-serial,chardev=charserial0,id=serial0 \
+-device isa-serial,chardev=charserial0,id=serial0,index=0 \
-chardev pty,id=charserial1 \
--device isa-serial,chardev=charserial1,id=serial1 \
+-device isa-serial,chardev=charserial1,id=serial1,index=1 \
-chardev
socket,id=charchannel0,path=/var/lib/libvirt/qemu/channel/target/gentoo.org.qemu.guest_agent.0,server=on,wait=off
\
-device
virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=org.qemu.guest_agent.0
\
-vnc 127.0.0.1:0 \
diff --git a/tests/qemuxml2argvdata/virtio-9p-createmode.x86_64-latest.args
b/tests/qemuxml2argvdata/virtio-9p-createmode.x86_64-latest.args
index 01fe01e3c6..d306b37b53 100644
--- a/tests/qemuxml2argvdata/virtio-9p-createmode.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/virtio-9p-createmode.x86_64-latest.args
@@ -37,7 +37,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
-fsdev local,security_model=mapped,id=fsdev-fs3,path=/export/fs3 \
-device
'{"driver":"virtio-9p-pci","id":"fs3","fsdev":"fsdev-fs3","mount_tag":"fs3","bus":"pci.0","addr":"0x5"}'
\
-chardev pty,id=charserial0 \
--device '{"driver":"isa-serial","chardev":"charserial0","id":"serial0"}' \
+-device
'{"driver":"isa-serial","chardev":"charserial0","id":"serial0","index":0}' \
-audiodev '{"id":"audio1","driver":"none"}' \
-device
'{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","addr":"0xc"}'
\
-sandbox
on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
diff --git a/tests/qemuxml2argvdata/virtio-9p-multidevs.x86_64-latest.args
b/tests/qemuxml2argvdata/virtio-9p-multidevs.x86_64-latest.args
index 8b325bb7ec..0752f09fe9 100644
--- a/tests/qemuxml2argvdata/virtio-9p-multidevs.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/virtio-9p-multidevs.x86_64-latest.args
@@ -35,7 +35,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
-fsdev
local,security_model=mapped,multidevs=warn,id=fsdev-fs2,path=/export/fs2 \
-device
'{"driver":"virtio-9p-pci","id":"fs2","fsdev":"fsdev-fs2","mount_tag":"fs2","bus":"pci.0","addr":"0x4"}'
\
-chardev pty,id=charserial0 \
--device '{"driver":"isa-serial","chardev":"charserial0","id":"serial0"}' \
+-device
'{"driver":"isa-serial","chardev":"charserial0","id":"serial0","index":0}' \
-audiodev '{"id":"audio1","driver":"none"}' \
-device
'{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","addr":"0xc"}'
\
-sandbox
on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
diff --git a/tests/qemuxml2argvdata/x86_64-pc-graphics.x86_64-latest.args
b/tests/qemuxml2argvdata/x86_64-pc-graphics.x86_64-latest.args
index 3cae9fafa0..8cad1d9f38 100644
--- a/tests/qemuxml2argvdata/x86_64-pc-graphics.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/x86_64-pc-graphics.x86_64-latest.args
@@ -37,7 +37,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \
-netdev user,id=hostnet0 \
-device
'{"driver":"virtio-net-pci","netdev":"hostnet0","id":"net0","mac":"52:54:00:4c:e3:86","bus":"pci.0","addr":"0x3"}'
\
-chardev pty,id=charserial0 \
--device '{"driver":"isa-serial","chardev":"charserial0","id":"serial0"}' \
+-device
'{"driver":"isa-serial","chardev":"charserial0","id":"serial0","index":0}' \
-chardev socket,id=charchannel0,fd=1729,server=on,wait=off \
-device
'{"driver":"virtserialport","bus":"virtio-serial0.0","nr":1,"chardev":"charchannel0","id":"channel0","name":"org.qemu.guest_agent.0"}'
\
-device '{"driver":"usb-tablet","id":"input0","bus":"usb.0","port":"1"}' \
diff --git a/tests/qemuxml2argvdata/x86_64-pc-headless.x86_64-latest.args
b/tests/qemuxml2argvdata/x86_64-pc-headless.x86_64-latest.args
index fbfb823d83..3c4688a89e 100644
--- a/tests/qemuxml2argvdata/x86_64-pc-headless.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/x86_64-pc-headless.x86_64-latest.args
@@ -38,7 +38,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \
-netdev user,id=hostnet0 \
-device
'{"driver":"virtio-net-pci","netdev":"hostnet0","id":"net0","mac":"52:54:00:09:a4:37","bus":"pci.0","addr":"0x2"}'
\
-chardev pty,id=charserial0 \
--device '{"driver":"isa-serial","chardev":"charserial0","id":"serial0"}' \
+-device
'{"driver":"isa-serial","chardev":"charserial0","id":"serial0","index":0}' \
-chardev socket,id=charchannel0,fd=1729,server=on,wait=off \
-device
'{"driver":"virtserialport","bus":"virtio-serial0.0","nr":1,"chardev":"charchannel0","id":"channel0","name":"org.qemu.guest_agent.0"}'
\
-audiodev '{"id":"audio1","driver":"none"}' \
diff --git a/tests/qemuxml2argvdata/x86_64-q35-graphics.x86_64-latest.args
b/tests/qemuxml2argvdata/x86_64-q35-graphics.x86_64-latest.args
index ca0e00f468..9e4c361ec9 100644
--- a/tests/qemuxml2argvdata/x86_64-q35-graphics.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/x86_64-q35-graphics.x86_64-latest.args
@@ -44,7 +44,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \
-netdev user,id=hostnet0 \
-device
'{"driver":"virtio-net-pci","netdev":"hostnet0","id":"net0","mac":"52:54:00:d2:70:0b","bus":"pci.1","addr":"0x0"}'
\
-chardev pty,id=charserial0 \
--device '{"driver":"isa-serial","chardev":"charserial0","id":"serial0"}' \
+-device
'{"driver":"isa-serial","chardev":"charserial0","id":"serial0","index":0}' \
-chardev socket,id=charchannel0,fd=1729,server=on,wait=off \
-device
'{"driver":"virtserialport","bus":"virtio-serial0.0","nr":1,"chardev":"charchannel0","id":"channel0","name":"org.qemu.guest_agent.0"}'
\
-device '{"driver":"usb-tablet","id":"input0","bus":"usb.0","port":"1"}' \
diff --git a/tests/qemuxml2argvdata/x86_64-q35-headless.x86_64-latest.args
b/tests/qemuxml2argvdata/x86_64-q35-headless.x86_64-latest.args
index c6970e349d..b4d90dff5e 100644
--- a/tests/qemuxml2argvdata/x86_64-q35-headless.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/x86_64-q35-headless.x86_64-latest.args
@@ -45,7 +45,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \
-netdev user,id=hostnet0 \
-device
'{"driver":"virtio-net-pci","netdev":"hostnet0","id":"net0","mac":"52:54:00:09:a4:37","bus":"pci.1","addr":"0x0"}'
\
-chardev pty,id=charserial0 \
--device '{"driver":"isa-serial","chardev":"charserial0","id":"serial0"}' \
+-device
'{"driver":"isa-serial","chardev":"charserial0","id":"serial0","index":0}' \
-chardev socket,id=charchannel0,fd=1729,server=on,wait=off \
-device
'{"driver":"virtserialport","bus":"virtio-serial0.0","nr":1,"chardev":"charchannel0","id":"channel0","name":"org.qemu.guest_agent.0"}'
\
-audiodev '{"id":"audio1","driver":"none"}' \
diff --git a/tests/qemuxml2xmloutdata/serial-tcp-tlsx509-chardev.xml
b/tests/qemuxml2xmloutdata/serial-tcp-tlsx509-chardev.xml
index 7fde19f283..de11465233 100644
--- a/tests/qemuxml2xmloutdata/serial-tcp-tlsx509-chardev.xml
+++ b/tests/qemuxml2xmloutdata/serial-tcp-tlsx509-chardev.xml
@@ -37,7 +37,7 @@
<serial type='tcp'>
<source mode='connect' host='127.0.0.1' service='5555'/>
<protocol type='raw'/>
- <target type='isa-serial' port='0'>
+ <target type='isa-serial' port='1'>
<model name='isa-serial'/>
</target>
</serial>