[libvirt] [PATCH 0/6 v2] qemu: virtio console support

The following series adds virtio console XML and qemu driver support. The first 5 patches are testing, documentation, and internal cleanups to prepare for the actual support added in patch 6. Changes from v1: Add more regression tests Always show an explicit <console> target type in the XML Drop multiple console support (there be dragons) Drop name attribute from virtio <console> target Cole Robinson (6): tests: Test qemuxml2xml when expected xml changes docs: domain: Document virtio <channel> domain conf: Rename character prop targetType -> deviceType domain conf: char: Add an explicit targetType field domain conf: Track <console> target type qemu: virtio console support docs/formatdomain.html.in | 30 ++- docs/schemas/domain.rng | 35 ++- src/conf/capabilities.h | 1 + src/conf/domain_conf.c | 462 +++++++++++++------- src/conf/domain_conf.h | 37 ++- src/esx/esx_vmx.c | 4 +- src/libvirt_private.syms | 1 + src/qemu/qemu_conf.c | 54 ++- src/qemu/qemu_driver.c | 4 +- src/uml/uml_conf.c | 2 + src/vbox/vbox_tmpl.c | 4 +- src/xen/xen_hypervisor.c | 2 + src/xen/xend_internal.c | 7 +- src/xen/xm_internal.c | 7 +- tests/Makefile.am | 1 + tests/define-dev-segfault | 2 +- tests/domainschematest | 2 +- .../qemuxml2argv-balloon-device-auto.args | 1 + .../qemuxml2argv-balloon-device-auto.xml | 22 + .../qemuxml2argv-console-compat-auto.args | 1 + .../qemuxml2argv-console-compat-auto.xml | 28 ++ .../qemuxml2argv-console-compat.xml | 2 +- .../qemuxml2argv-console-virtio.args | 1 + .../qemuxml2argv-console-virtio.xml | 27 ++ .../qemuxml2argv-disk-scsi-device-auto.args | 1 + .../qemuxml2argv-disk-scsi-device-auto.xml | 28 ++ .../qemuxml2argv-disk-scsi-device.args | 1 + .../qemuxml2argv-disk-scsi-device.xml | 31 ++ tests/qemuxml2argvdata/qemuxml2argv-serial-dev.xml | 2 +- .../qemuxml2argvdata/qemuxml2argv-serial-file.xml | 2 +- .../qemuxml2argvdata/qemuxml2argv-serial-many.xml | 2 +- tests/qemuxml2argvdata/qemuxml2argv-serial-pty.xml | 2 +- .../qemuxml2argv-serial-tcp-telnet.xml | 2 +- tests/qemuxml2argvdata/qemuxml2argv-serial-tcp.xml | 2 +- tests/qemuxml2argvdata/qemuxml2argv-serial-udp.xml | 2 +- .../qemuxml2argvdata/qemuxml2argv-serial-unix.xml | 2 +- tests/qemuxml2argvdata/qemuxml2argv-serial-vc.xml | 2 +- tests/qemuxml2argvtest.c | 9 + .../qemuxml2xmlout-balloon-device-auto.xml | 25 + .../qemuxml2xmlout-channel-virtio-auto.xml | 54 +++ .../qemuxml2xmlout-console-compat-auto.xml | 31 ++ .../qemuxml2xmlout-console-virtio.xml | 29 ++ .../qemuxml2xmlout-disk-scsi-device-auto.xml | 31 ++ tests/qemuxml2xmltest.c | 80 +++- tests/sexpr2xmldata/sexpr2xml-bridge-ipaddr.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-curmem.xml | 2 +- .../sexpr2xml-disk-block-shareable.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-disk-block.xml | 2 +- .../sexpr2xml-disk-drv-blktap-qcow.xml | 2 +- .../sexpr2xml-disk-drv-blktap-raw.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-disk-file.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-kernel.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml | 2 +- .../sexpr2xml-fv-serial-tcp-telnet.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-net-bridged.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-net-e1000.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-net-routed.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-pci-devs.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-pv-bootloader.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-pv-localtime.xml | 2 +- .../sexpr2xml-pv-vfb-new-vncdisplay.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-pv-vfb-orig.xml | 2 +- .../sexpr2xmldata/sexpr2xml-pv-vfb-type-crash.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-pv.xml | 2 +- tests/vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml | 2 +- tests/vmx2xmldata/vmx2xml-serial-device.xml | 2 +- tests/vmx2xmldata/vmx2xml-serial-file.xml | 2 +- tests/vmx2xmldata/vmx2xml-serial-pipe.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-file.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-null.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-pipe.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-pty.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-stdio.xml | 2 +- .../test-fullvirt-serial-tcp-telnet.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-tcp.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-udp.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-unix.xml | 2 +- tests/xmconfigdata/test-no-source-cdrom.xml | 2 +- tests/xmconfigdata/test-paravirt-net-e1000.xml | 2 +- tests/xmconfigdata/test-paravirt-net-vifname.xml | 2 +- .../test-paravirt-new-pvfb-vncdisplay.xml | 2 +- tests/xmconfigdata/test-paravirt-new-pvfb.xml | 2 +- .../test-paravirt-old-pvfb-vncdisplay.xml | 2 +- tests/xmconfigdata/test-paravirt-old-pvfb.xml | 2 +- tests/xmconfigdata/test-pci-devs.xml | 2 +- 95 files changed, 900 insertions(+), 277 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-balloon-device-auto.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-balloon-device-auto.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-compat-auto.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-compat-auto.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-virtio.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-virtio.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device-auto.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device-auto.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-balloon-device-auto.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-auto.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-scsi-device-auto.xml

Add tests for auto memballon, implicit IDE, SCSI, virtio channel controllers, and console/serial back compat. Additionally, an explicit qemuxml2argvtest for scsi disks is added. Signed-off-by: Cole Robinson <crobinso@redhat.com> --- tests/Makefile.am | 1 + tests/domainschematest | 2 +- .../qemuxml2argv-balloon-device-auto.args | 1 + .../qemuxml2argv-balloon-device-auto.xml | 22 ++++++ .../qemuxml2argv-console-compat-auto.args | 1 + .../qemuxml2argv-console-compat-auto.xml | 28 +++++++ .../qemuxml2argv-disk-scsi-device-auto.args | 1 + .../qemuxml2argv-disk-scsi-device-auto.xml | 28 +++++++ .../qemuxml2argv-disk-scsi-device.args | 1 + .../qemuxml2argv-disk-scsi-device.xml | 31 ++++++++ tests/qemuxml2argvtest.c | 7 ++ .../qemuxml2xmlout-balloon-device-auto.xml | 25 ++++++ .../qemuxml2xmlout-channel-virtio-auto.xml | 54 +++++++++++++ .../qemuxml2xmlout-console-compat-auto.xml | 31 ++++++++ .../qemuxml2xmlout-disk-scsi-device-auto.xml | 31 ++++++++ tests/qemuxml2xmltest.c | 79 +++++++++++++++----- 16 files changed, 324 insertions(+), 19 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-balloon-device-auto.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-balloon-device-auto.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-compat-auto.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-compat-auto.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device-auto.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device-auto.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-balloon-device-auto.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-auto.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-scsi-device-auto.xml diff --git a/tests/Makefile.am b/tests/Makefile.am index a3661f6..71c2c74 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -43,6 +43,7 @@ EXTRA_DIST = \ oomtrace.pl \ test-lib.sh \ qemuxml2argvdata \ + qemuxml2xmloutdata \ nodeinfodata \ schematestutils.sh \ capabilityschematest \ diff --git a/tests/domainschematest b/tests/domainschematest index d513f5a..7557cef 100755 --- a/tests/domainschematest +++ b/tests/domainschematest @@ -4,7 +4,7 @@ . $srcdir/test-lib.sh . $abs_srcdir/schematestutils.sh -DIRS="domainschemadata qemuxml2argvdata sexpr2xmldata xmconfigdata xml2sexprdata" +DIRS="domainschemadata qemuxml2argvdata sexpr2xmldata xmconfigdata xml2sexprdata qemuxml2xmloutdata" SCHEMA="domain.rng" check_schema "$DIRS" "$SCHEMA" diff --git a/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-auto.args b/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-auto.args new file mode 100644 index 0000000..08f0b8a --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-auto.args @@ -0,0 +1 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-auto.xml b/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-auto.xml new file mode 100644 index 0000000..26c9b25 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-auto.xml @@ -0,0 +1,22 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory>219200</memory> + <currentMemory>219200</currentMemory> + <vcpu>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <disk type='block' device='disk'> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + </disk> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-compat-auto.args b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-auto.args new file mode 100644 index 0000000..fd42462 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-auto.args @@ -0,0 +1 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial pty -parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-compat-auto.xml b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-auto.xml new file mode 100644 index 0000000..f0e875e --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-auto.xml @@ -0,0 +1,28 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory>219200</memory> + <currentMemory>219200</currentMemory> + <vcpu>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <disk type='block' device='disk'> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' unit='0'/> + </disk> + <controller type='ide' index='0'/> + <console type='pty'> + <target port='0'/> + </console> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device-auto.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device-auto.args new file mode 100644 index 0000000..e29a4e8 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device-auto.args @@ -0,0 +1 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -device lsi,id=scsi0,bus=pci.0,addr=0x2 -drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-ide0-0-0 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -drive file=/tmp/scsidisk.img,if=none,id=drive-scsi0-0-0 -device scsi-disk,bus=scsi0.0,scsi-id=0,drive=drive-scsi0-0-0,id=scsi0-0-0 -usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device-auto.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device-auto.xml new file mode 100644 index 0000000..df50a27 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device-auto.xml @@ -0,0 +1,28 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory>219200</memory> + <currentMemory>219200</currentMemory> + <vcpu>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <disk type='block' device='disk'> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + </disk> + <controller type='ide' index='0'/> + <disk type='file' device='disk'> + <source file='/tmp/scsidisk.img'/> + <target dev='sda' bus='scsi'/> + </disk> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device.args new file mode 100644 index 0000000..e29a4e8 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device.args @@ -0,0 +1 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -device lsi,id=scsi0,bus=pci.0,addr=0x2 -drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-ide0-0-0 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -drive file=/tmp/scsidisk.img,if=none,id=drive-scsi0-0-0 -device scsi-disk,bus=scsi0.0,scsi-id=0,drive=drive-scsi0-0-0,id=scsi0-0-0 -usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device.xml new file mode 100644 index 0000000..a250940 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device.xml @@ -0,0 +1,31 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory>219200</memory> + <currentMemory>219200</currentMemory> + <vcpu>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <disk type='block' device='disk'> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' unit='0'/> + </disk> + <disk type='file' device='disk'> + <source file='/tmp/scsidisk.img'/> + <target dev='sda' bus='scsi'/> + <address type='drive' controller='0' bus='0' unit='0'/> + </disk> + <controller type='ide' index='0'/> + <controller type='scsi' index='0'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 3d6c583..566ab6b 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -273,6 +273,10 @@ mymain(int argc, char **argv) DO_TEST("disk-usb", 0); DO_TEST("disk-usb-device", QEMUD_CMD_FLAG_DRIVE | QEMUD_CMD_FLAG_DEVICE | QEMUD_CMD_FLAG_NODEFCONFIG); + DO_TEST("disk-scsi-device", QEMUD_CMD_FLAG_DRIVE | + QEMUD_CMD_FLAG_DEVICE | QEMUD_CMD_FLAG_NODEFCONFIG); + DO_TEST("disk-scsi-device-auto", QEMUD_CMD_FLAG_DRIVE | + QEMUD_CMD_FLAG_DEVICE | QEMUD_CMD_FLAG_NODEFCONFIG); DO_TEST("graphics-vnc", 0); driver.vncSASL = 1; @@ -318,6 +322,7 @@ mymain(int argc, char **argv) DO_TEST("serial-many", 0); DO_TEST("parallel-tcp", 0); DO_TEST("console-compat", 0); + DO_TEST("console-compat-auto", 0); DO_TEST("serial-vc-chardev", QEMUD_CMD_FLAG_CHARDEV|QEMUD_CMD_FLAG_DEVICE | QEMUD_CMD_FLAG_NODEFCONFIG); @@ -354,6 +359,8 @@ mymain(int argc, char **argv) QEMUD_CMD_FLAG_NODEFCONFIG); DO_TEST("balloon-device", QEMUD_CMD_FLAG_DEVICE | QEMUD_CMD_FLAG_NODEFCONFIG); + DO_TEST("balloon-device-auto", QEMUD_CMD_FLAG_DEVICE | + QEMUD_CMD_FLAG_NODEFCONFIG); DO_TEST("sound", 0); DO_TEST("sound-device", QEMUD_CMD_FLAG_DEVICE | QEMUD_CMD_FLAG_NODEFCONFIG); diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-balloon-device-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-balloon-device-auto.xml new file mode 100644 index 0000000..ed91e37 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-balloon-device-auto.xml @@ -0,0 +1,25 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory>219200</memory> + <currentMemory>219200</currentMemory> + <vcpu>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <disk type='block' device='disk'> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' unit='0'/> + </disk> + <controller type='ide' index='0'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-auto.xml new file mode 100644 index 0000000..7990374 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-auto.xml @@ -0,0 +1,54 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory>219200</memory> + <currentMemory>219200</currentMemory> + <vcpu cpuset='1-4,8-20,525'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <disk type='block' device='disk'> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' unit='0'/> + </disk> + <controller type='ide' index='0'/> + <controller type='virtio-serial' index='0' ports='16' vectors='4'/> + <controller type='virtio-serial' index='1'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/> + </controller> + <controller type='virtio-serial' index='2'/> + <channel type='pty'> + <target type='virtio' name='org.linux-kvm.port.0'/> + <address type='virtio-serial' controller='0' bus='0' port='0'/> + </channel> + <channel type='pty'> + <target type='virtio' name='org.linux-kvm.port.foo'/> + <address type='virtio-serial' controller='1' bus='0' port='0'/> + </channel> + <channel type='pty'> + <target type='virtio' name='org.linux-kvm.port.bar'/> + <address type='virtio-serial' controller='1' bus='0' port='3'/> + </channel> + <channel type='pty'> + <target type='virtio' name='org.linux-kvm.port.wizz'/> + <address type='virtio-serial' controller='0' bus='0' port='1'/> + </channel> + <channel type='pty'> + <target type='virtio' name='org.linux-kvm.port.ooh'/> + <address type='virtio-serial' controller='1' bus='0' port='4'/> + </channel> + <channel type='pty'> + <target type='virtio' name='org.linux-kvm.port.lla'/> + <address type='virtio-serial' controller='2' bus='0' port='0'/> + </channel> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml new file mode 100644 index 0000000..611ddb8 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml @@ -0,0 +1,31 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory>219200</memory> + <currentMemory>219200</currentMemory> + <vcpu>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <disk type='block' device='disk'> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' unit='0'/> + </disk> + <controller type='ide' index='0'/> + <serial type='pty'> + <target port='0'/> + </serial> + <console type='pty'> + <target port='0'/> + </console> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-scsi-device-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-scsi-device-auto.xml new file mode 100644 index 0000000..a250940 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-scsi-device-auto.xml @@ -0,0 +1,31 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory>219200</memory> + <currentMemory>219200</currentMemory> + <vcpu>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <disk type='block' device='disk'> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' unit='0'/> + </disk> + <disk type='file' device='disk'> + <source file='/tmp/scsidisk.img'/> + <target dev='sda' bus='scsi'/> + <address type='drive' controller='0' bus='0' unit='0'/> + </disk> + <controller type='ide' index='0'/> + <controller type='scsi' index='0'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 69829b1..08e0e73 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -22,41 +22,63 @@ static struct qemud_driver driver; # define MAX_FILE 4096 -static int testCompareXMLToXMLFiles(const char *xml) { - char xmlData[MAX_FILE]; - char *xmlPtr = &(xmlData[0]); +static int testCompareXMLToXMLFiles(const char *inxml, const char *outxml) { + char inXmlData[MAX_FILE]; + char *inXmlPtr = &(inXmlData[0]); + char outXmlData[MAX_FILE]; + char *outXmlPtr = &(outXmlData[0]); char *actual = NULL; int ret = -1; - virDomainDefPtr vmdef = NULL; + virDomainDefPtr def = NULL; - if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0) + if (virtTestLoadFile(inxml, &inXmlPtr, MAX_FILE) < 0) + goto fail; + if (virtTestLoadFile(outxml, &outXmlPtr, MAX_FILE) < 0) goto fail; - if (!(vmdef = virDomainDefParseString(driver.caps, xmlData, + if (!(def = virDomainDefParseString(driver.caps, inXmlData, VIR_DOMAIN_XML_INACTIVE))) goto fail; - if (!(actual = virDomainDefFormat(vmdef, 0))) + if (!(actual = virDomainDefFormat(def, 0))) goto fail; - if (STRNEQ(xmlData, actual)) { - virtTestDifference(stderr, xmlData, actual); + + if (STRNEQ(outXmlData, actual)) { + virtTestDifference(stderr, outXmlData, actual); goto fail; } ret = 0; - fail: free(actual); - virDomainDefFree(vmdef); + virDomainDefFree(def); return ret; } +struct testInfo { + const char *name; + int different; +}; + static int testCompareXMLToXMLHelper(const void *data) { - char xml[PATH_MAX]; - snprintf(xml, PATH_MAX, "%s/qemuxml2argvdata/qemuxml2argv-%s.xml", - abs_srcdir, (const char*)data); - return testCompareXMLToXMLFiles(xml); + const struct testInfo *info = data; + char xml_in[PATH_MAX]; + char xml_out[PATH_MAX]; + int ret; + + snprintf(xml_in, PATH_MAX, "%s/qemuxml2argvdata/qemuxml2argv-%s.xml", + abs_srcdir, info->name); + snprintf(xml_out, PATH_MAX, "%s/qemuxml2xmloutdata/qemuxml2xmlout-%s.xml", + abs_srcdir, info->name); + + if (info->different) { + ret = testCompareXMLToXMLFiles(xml_in, xml_out); + } else { + ret = testCompareXMLToXMLFiles(xml_in, xml_in); + } + + return ret; } @@ -80,10 +102,24 @@ mymain(int argc, char **argv) if ((driver.caps = testQemuCapsInit()) == NULL) return (EXIT_FAILURE); +# define DO_TEST_FULL(name, is_different) \ + do { \ + const struct testInfo info = {name, is_different}; \ + if (virtTestRun("QEMU XML-2-XML " name, \ + 1, testCompareXMLToXMLHelper, &info) < 0) \ + ret = -1; \ + } while (0) + # define DO_TEST(name) \ - if (virtTestRun("QEMU XML-2-XML " name, \ - 1, testCompareXMLToXMLHelper, (name)) < 0) \ - ret = -1 + DO_TEST_FULL(name, 0) + +# define DO_TEST_DIFFERENT(name) \ + DO_TEST_FULL(name, 1) + + /* Unset or set all envvars here that are copied in qemudBuildCommandLine + * using ADD_ENV_COPY, otherwise these tests may fail due to unexpected + * values for these envvars */ + setenv("PATH", "/bin", 1); DO_TEST("minimal"); DO_TEST("boot-cdrom"); @@ -105,6 +141,7 @@ mymain(int argc, char **argv) DO_TEST("disk-drive-cache-v1-wt"); DO_TEST("disk-drive-cache-v1-wb"); DO_TEST("disk-drive-cache-v1-none"); + DO_TEST("disk-scsi-device"); DO_TEST("graphics-vnc"); DO_TEST("graphics-vnc-sasl"); DO_TEST("graphics-vnc-tls"); @@ -140,6 +177,12 @@ mymain(int argc, char **argv) DO_TEST("encrypted-disk"); + /* These tests generate different XML */ + DO_TEST_DIFFERENT("balloon-device-auto"); + DO_TEST_DIFFERENT("channel-virtio-auto"); + DO_TEST_DIFFERENT("console-compat-auto"); + DO_TEST_DIFFERENT("disk-scsi-device-auto"); + virCapabilitiesFree(driver.caps); return (ret==0 ? EXIT_SUCCESS : EXIT_FAILURE); -- 1.7.1.1

On Mon, Jul 26, 2010 at 03:16:20PM -0400, Cole Robinson wrote:
Add tests for auto memballon, implicit IDE, SCSI, virtio channel controllers, and console/serial back compat.
Additionally, an explicit qemuxml2argvtest for scsi disks is added.
Signed-off-by: Cole Robinson <crobinso@redhat.com>
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

Signed-off-by: Cole Robinson <crobinso@redhat.com> --- docs/formatdomain.html.in | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 3e80312..8714a14 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1158,6 +1158,11 @@ qemu-kvm -net nic,model=? /dev/null <source mode='bind' path='/tmp/guestfwd'/> <target type='guestfwd' address='10.0.2.1' port='4600'/> </channel> + + <!-- KVM virtio channel --> + <channel type='pty'> + <target type='virtio' name='arbitrary.virtio.serial.port.name'/> + </channel> </devices> ...</pre> @@ -1174,6 +1179,13 @@ qemu-kvm -net nic,model=? /dev/null forwarded to the channel device on the host. The <code>target</code> element must have <code>address</code> and <code>port</code> attributes. <span class="since">Since 0.7.3</span></dd> + + <dt><code>virtio</code></dt> + <dd>Paravirtualized virtio channel. Channel is exposed in the guest under + /dev/vport*, and if the optional element<code>name</code> is specified, + /dev/virtio-ports/$name (for more info, please see + <a href="http://fedoraproject.org/wiki/Features/VirtioSerial">http://fedoraproject.org/wiki/Features/VirtioSerial</a>) + <span class="since">Since 0.7.7</span></dd> </dl> <h5><a name="elementsCharHostInterface">Host interface</a></h5> -- 1.7.1.1

On Mon, Jul 26, 2010 at 03:16:21PM -0400, Cole Robinson wrote:
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- docs/formatdomain.html.in | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 3e80312..8714a14 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1158,6 +1158,11 @@ qemu-kvm -net nic,model=? /dev/null <source mode='bind' path='/tmp/guestfwd'/> <target type='guestfwd' address='10.0.2.1' port='4600'/> </channel> + + <!-- KVM virtio channel --> + <channel type='pty'> + <target type='virtio' name='arbitrary.virtio.serial.port.name'/> + </channel> </devices> ...</pre>
@@ -1174,6 +1179,13 @@ qemu-kvm -net nic,model=? /dev/null forwarded to the channel device on the host. The <code>target</code> element must have <code>address</code> and <code>port</code> attributes. <span class="since">Since 0.7.3</span></dd> + + <dt><code>virtio</code></dt> + <dd>Paravirtualized virtio channel. Channel is exposed in the guest under + /dev/vport*, and if the optional element<code>name</code> is specified, + /dev/virtio-ports/$name (for more info, please see + <a href="http://fedoraproject.org/wiki/Features/VirtioSerial">http://fedoraproject.org/wiki/Features/VirtioSerial</a>) + <span class="since">Since 0.7.7</span></dd> </dl>
<h5><a name="elementsCharHostInterface">Host interface</a></h5>
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

There is actually a difference between the character device type (serial, parallel, channel, ...) and the target type (virtio, guestfwd). Currently they are awkwardly conflated. Start to pull them apart by renaming targetType -> deviceType. This is an entirely mechanical change. Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/conf/domain_conf.c | 74 +++++++++++++++++++++++----------------------- src/conf/domain_conf.h | 22 +++++++------- src/esx/esx_vmx.c | 4 +- src/qemu/qemu_conf.c | 10 +++--- src/qemu/qemu_driver.c | 2 +- src/vbox/vbox_tmpl.c | 4 +- src/xen/xend_internal.c | 6 ++-- src/xen/xm_internal.c | 6 ++-- 8 files changed, 64 insertions(+), 64 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5b59c01..faf1629 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -164,7 +164,7 @@ VIR_ENUM_IMPL(virDomainNet, VIR_DOMAIN_NET_TYPE_LAST, "internal", "direct") -VIR_ENUM_IMPL(virDomainChrTarget, VIR_DOMAIN_CHR_TARGET_TYPE_LAST, +VIR_ENUM_IMPL(virDomainChrDevice, VIR_DOMAIN_CHR_DEVICE_TYPE_LAST, "null", "monitor", "parallel", @@ -523,12 +523,12 @@ void virDomainChrDefFree(virDomainChrDefPtr def) if (!def) return; - switch (def->targetType) { - case VIR_DOMAIN_CHR_TARGET_TYPE_GUESTFWD: + switch (def->deviceType) { + case VIR_DOMAIN_CHR_DEVICE_TYPE_GUESTFWD: VIR_FREE(def->target.addr); break; - case VIR_DOMAIN_CHR_TARGET_TYPE_VIRTIO: + case VIR_DOMAIN_CHR_DEVICE_TYPE_VIRTIO: VIR_FREE(def->target.name); break; } @@ -2415,7 +2415,7 @@ virDomainChrDefParseXML(xmlNodePtr node, char *mode = NULL; char *protocol = NULL; const char *nodeName; - const char *targetType = NULL; + const char *deviceType = NULL; const char *addrStr = NULL; const char *portStr = NULL; virDomainChrDefPtr def; @@ -2432,7 +2432,7 @@ virDomainChrDefParseXML(xmlNodePtr node, def->type = VIR_DOMAIN_CHR_TYPE_NULL; nodeName = (const char *) node->name; - if ((def->targetType = virDomainChrTargetTypeFromString(nodeName)) < 0) { + if ((def->deviceType = virDomainChrDeviceTypeFromString(nodeName)) < 0) { /* channel is handled below */ if (STRNEQ(nodeName, "channel")) { virDomainReportError(VIR_ERR_XML_ERROR, @@ -2441,7 +2441,7 @@ virDomainChrDefParseXML(xmlNodePtr node, VIR_FREE(def); return NULL; } - def->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_NULL; + def->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_NULL; } cur = node->children; @@ -2491,30 +2491,30 @@ virDomainChrDefParseXML(xmlNodePtr node, protocol = virXMLPropString(cur, "type"); } else if (xmlStrEqual(cur->name, BAD_CAST "target")) { /* If target type isn't set yet, expect it to be set here */ - if (def->targetType == VIR_DOMAIN_CHR_TARGET_TYPE_NULL) { - targetType = virXMLPropString(cur, "type"); - if (targetType == NULL) { + if (def->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_NULL) { + deviceType = virXMLPropString(cur, "type"); + if (deviceType == NULL) { virDomainReportError(VIR_ERR_XML_ERROR, "%s", _("character device target does " "not define a type")); goto error; } - if ((def->targetType = - virDomainChrTargetTypeFromString(targetType)) < 0) + if ((def->deviceType = + virDomainChrDeviceTypeFromString(deviceType)) < 0) { virDomainReportError(VIR_ERR_XML_ERROR, _("unknown target type for " "character device: %s"), - targetType); + deviceType); goto error; } } unsigned int port; - switch (def->targetType) { - case VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL: - case VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL: - case VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE: + switch (def->deviceType) { + case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: + case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: + case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: portStr = virXMLPropString(cur, "port"); if (portStr == NULL) { /* Not required. It will be assigned automatically @@ -2530,7 +2530,7 @@ virDomainChrDefParseXML(xmlNodePtr node, } break; - case VIR_DOMAIN_CHR_TARGET_TYPE_GUESTFWD: + case VIR_DOMAIN_CHR_DEVICE_TYPE_GUESTFWD: addrStr = virXMLPropString(cur, "address"); portStr = virXMLPropString(cur, "port"); @@ -2574,14 +2574,14 @@ virDomainChrDefParseXML(xmlNodePtr node, virSocketSetPort(def->target.addr, port); break; - case VIR_DOMAIN_CHR_TARGET_TYPE_VIRTIO: + case VIR_DOMAIN_CHR_DEVICE_TYPE_VIRTIO: def->target.name = virXMLPropString(cur, "name"); break; default: virDomainReportError(VIR_ERR_XML_ERROR, _("unexpected target type type %u"), - def->targetType); + def->deviceType); } } } @@ -2714,7 +2714,7 @@ cleanup: VIR_FREE(connectHost); VIR_FREE(connectService); VIR_FREE(path); - VIR_FREE(targetType); + VIR_FREE(deviceType); VIR_FREE(addrStr); VIR_FREE(portStr); @@ -4473,7 +4473,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, } def->nserials = 1; def->serials[0] = chr; - chr->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL; + chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; } } else { def->console = chr; @@ -4496,7 +4496,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, def->channels[def->nchannels++] = chr; - if (chr->targetType == VIR_DOMAIN_CHR_TARGET_TYPE_VIRTIO && + if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_VIRTIO && chr->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) chr->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL; @@ -5011,7 +5011,7 @@ static int virDomainDefMaybeAddVirtioSerialController(virDomainDefPtr def) for (i = 0 ; i < def->nchannels ; i++) { virDomainChrDefPtr channel = def->channels[i]; - if (channel->targetType == VIR_DOMAIN_CHR_TARGET_TYPE_VIRTIO) { + if (channel->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_VIRTIO) { int idx = 0; if (channel->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL) idx = channel->info.addr.vioserial.controller; @@ -5593,15 +5593,15 @@ virDomainChrDefFormat(virBufferPtr buf, int flags) { const char *type = virDomainChrTypeToString(def->type); - const char *targetName = virDomainChrTargetTypeToString(def->targetType); + const char *targetName = virDomainChrDeviceTypeToString(def->deviceType); const char *elementName; int ret = 0; - switch (def->targetType) { + switch (def->deviceType) { /* channel types are in a common channel element */ - case VIR_DOMAIN_CHR_TARGET_TYPE_GUESTFWD: - case VIR_DOMAIN_CHR_TARGET_TYPE_VIRTIO: + case VIR_DOMAIN_CHR_DEVICE_TYPE_GUESTFWD: + case VIR_DOMAIN_CHR_DEVICE_TYPE_VIRTIO: elementName = "channel"; break; @@ -5618,7 +5618,7 @@ virDomainChrDefFormat(virBufferPtr buf, /* Compat with legacy <console tty='/dev/pts/5'/> syntax */ virBufferVSprintf(buf, " <%s type='%s'", elementName, type); - if (def->targetType == VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE && + if (def->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && def->type == VIR_DOMAIN_CHR_TYPE_PTY && !(flags & VIR_DOMAIN_XML_INACTIVE) && def->data.file.path) { @@ -5693,8 +5693,8 @@ virDomainChrDefFormat(virBufferPtr buf, break; } - switch (def->targetType) { - case VIR_DOMAIN_CHR_TARGET_TYPE_GUESTFWD: + switch (def->deviceType) { + case VIR_DOMAIN_CHR_DEVICE_TYPE_GUESTFWD: { int port = virSocketGetPort(def->target.addr); if (port < 0) { @@ -5715,7 +5715,7 @@ virDomainChrDefFormat(virBufferPtr buf, break; } - case VIR_DOMAIN_CHR_TARGET_TYPE_VIRTIO: + case VIR_DOMAIN_CHR_DEVICE_TYPE_VIRTIO: virBufferAddLit(buf, " <target type='virtio'"); if (def->target.name) { virBufferEscapeString(buf, " name='%s'", def->target.name); @@ -5723,16 +5723,16 @@ virDomainChrDefFormat(virBufferPtr buf, virBufferAddLit(buf, "/>\n"); break; - case VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL: - case VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL: - case VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE: + case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: + case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: + case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: virBufferVSprintf(buf, " <target port='%d'/>\n", def->target.port); break; default: virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected character destination type %d"), - def->targetType); + def->deviceType); return -1; } @@ -6370,7 +6370,7 @@ char *virDomainDefFormat(virDomainDefPtr def, * console */ virDomainChrDef console; memcpy(&console, def->serials[0], sizeof(console)); - console.targetType = VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE; + console.deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE; if (virDomainChrDefFormat(&buf, &console, flags) < 0) goto cleanup; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 9ef687b..86cc02a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -313,16 +313,16 @@ struct _virDomainNetDef { virNWFilterHashTablePtr filterparams; }; -enum virDomainChrTargetType { - VIR_DOMAIN_CHR_TARGET_TYPE_NULL = 0, - VIR_DOMAIN_CHR_TARGET_TYPE_MONITOR, - VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL, - VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL, - VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE, - VIR_DOMAIN_CHR_TARGET_TYPE_GUESTFWD, - VIR_DOMAIN_CHR_TARGET_TYPE_VIRTIO, +enum virDomainChrDeviceType { + VIR_DOMAIN_CHR_DEVICE_TYPE_NULL = 0, + VIR_DOMAIN_CHR_DEVICE_TYPE_MONITOR, + VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL, + VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL, + VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE, + VIR_DOMAIN_CHR_DEVICE_TYPE_GUESTFWD, + VIR_DOMAIN_CHR_DEVICE_TYPE_VIRTIO, - VIR_DOMAIN_CHR_TARGET_TYPE_LAST + VIR_DOMAIN_CHR_DEVICE_TYPE_LAST }; enum virDomainChrType { @@ -350,7 +350,7 @@ enum virDomainChrTcpProtocol { typedef struct _virDomainChrDef virDomainChrDef; typedef virDomainChrDef *virDomainChrDefPtr; struct _virDomainChrDef { - int targetType; + int deviceType; union { int port; /* parallel, serial, console */ virSocketAddrPtr addr; /* guestfwd */ @@ -1129,7 +1129,7 @@ VIR_ENUM_DECL(virDomainController) VIR_ENUM_DECL(virDomainControllerModel) VIR_ENUM_DECL(virDomainFS) VIR_ENUM_DECL(virDomainNet) -VIR_ENUM_DECL(virDomainChrTarget) +VIR_ENUM_DECL(virDomainChrDevice) VIR_ENUM_DECL(virDomainChr) VIR_ENUM_DECL(virDomainSoundModel) VIR_ENUM_DECL(virDomainMemballoonModel) diff --git a/src/esx/esx_vmx.c b/src/esx/esx_vmx.c index c63b159..28bddc9 100644 --- a/src/esx/esx_vmx.c +++ b/src/esx/esx_vmx.c @@ -2396,7 +2396,7 @@ esxVMX_ParseSerial(esxVI_Context *ctx, virConfPtr conf, int port, return -1; } - (*def)->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL; + (*def)->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; snprintf(prefix, sizeof(prefix), "serial%d", port); @@ -2526,7 +2526,7 @@ esxVMX_ParseParallel(esxVI_Context *ctx, virConfPtr conf, int port, return -1; } - (*def)->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL; + (*def)->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL; snprintf(prefix, sizeof(prefix), "parallel%d", port); diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 0dbab48..bcca274 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -4477,8 +4477,8 @@ int qemudBuildCommandLine(virConnectPtr conn, virDomainChrDefPtr channel = def->channels[i]; char *devstr; - switch(channel->targetType) { - case VIR_DOMAIN_CHR_TARGET_TYPE_GUESTFWD: + switch(channel->deviceType) { + case VIR_DOMAIN_CHR_DEVICE_TYPE_GUESTFWD: if (!(qemuCmdFlags & QEMUD_CMD_FLAG_CHARDEV) || !(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) { qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -4504,7 +4504,7 @@ int qemudBuildCommandLine(virConnectPtr conn, ADD_ARG(devstr); break; - case VIR_DOMAIN_CHR_TARGET_TYPE_VIRTIO: + case VIR_DOMAIN_CHR_DEVICE_TYPE_VIRTIO: if (!(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) { qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("virtio channel requires QEMU to support -device")); @@ -6215,7 +6215,7 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps, virDomainChrDefFree(chr); goto no_memory; } - chr->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL; + chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; chr->target.port = def->nserials; def->serials[def->nserials++] = chr; } @@ -6229,7 +6229,7 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps, virDomainChrDefFree(chr); goto no_memory; } - chr->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL; + chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL; chr->target.port = def->nparallels; def->parallels[def->nparallels++] = chr; } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d0bbc63..4558674 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3557,7 +3557,7 @@ qemuPrepareMonitorChr(struct qemud_driver *driver, virDomainChrDefPtr monConfig, const char *vm) { - monConfig->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_MONITOR; + monConfig->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_MONITOR; monConfig->type = VIR_DOMAIN_CHR_TYPE_UNIX; monConfig->data.nix.listen = 1; diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index edc7a72..0a91c7f 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -2839,7 +2839,7 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) { def->serials[serialPortIncCount]->type = VIR_DOMAIN_CHR_TYPE_NULL; } - def->serials[serialPortIncCount]->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL; + def->serials[serialPortIncCount]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; serialPort->vtbl->GetIRQ(serialPort, &IRQ); serialPort->vtbl->GetIOBase(serialPort, &IOBase); @@ -2918,7 +2918,7 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) { } def->parallels[parallelPortIncCount]->type = VIR_DOMAIN_CHR_TYPE_FILE; - def->parallels[parallelPortIncCount]->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL; + def->parallels[parallelPortIncCount]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL; parallelPort->vtbl->GetPath(parallelPort, &pathUtf16); diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c index a22d32b..a492231 100644 --- a/src/xen/xend_internal.c +++ b/src/xen/xend_internal.c @@ -2346,7 +2346,7 @@ xenDaemonParseSxpr(virConnectPtr conn, virDomainChrDefFree(chr); goto no_memory; } - chr->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL; + chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; def->serials[def->nserials++] = chr; } tmp = sexpr_node(root, "domain/image/hvm/parallel"); @@ -2359,14 +2359,14 @@ xenDaemonParseSxpr(virConnectPtr conn, virDomainChrDefFree(chr); goto no_memory; } - chr->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL; + chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL; def->parallels[def->nparallels++] = chr; } } else { /* Fake a paravirt console, since that's not in the sexpr */ if (!(def->console = xenDaemonParseSxprChar("pty", tty))) goto error; - def->console->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE; + def->console->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE; } VIR_FREE(tty); diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c index a7a09a0..4230504 100644 --- a/src/xen/xm_internal.c +++ b/src/xen/xm_internal.c @@ -1416,7 +1416,7 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) { virDomainChrDefFree(chr); goto no_memory; } - chr->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL; + chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL; def->parallels[0] = chr; def->nparallels++; chr = NULL; @@ -1433,14 +1433,14 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) { virDomainChrDefFree(chr); goto no_memory; } - chr->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL; + chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; def->serials[0] = chr; def->nserials++; } } else { if (!(def->console = xenDaemonParseSxprChar("pty", NULL))) goto cleanup; - def->console->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE; + def->console->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE; } if (hvm) { -- 1.7.1.1

On Mon, Jul 26, 2010 at 03:16:22PM -0400, Cole Robinson wrote:
There is actually a difference between the character device type (serial, parallel, channel, ...) and the target type (virtio, guestfwd). Currently they are awkwardly conflated.
Start to pull them apart by renaming targetType -> deviceType. This is an entirely mechanical change.
Signed-off-by: Cole Robinson <crobinso@redhat.com>
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

targetType only tracks the actual <target> format we are parsing. Currently we only fill abide this value for channel devices. Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/conf/domain_conf.c | 379 +++++++++++++++++++++++++++++------------------ src/conf/domain_conf.h | 17 ++- src/qemu/qemu_conf.c | 6 +- 3 files changed, 249 insertions(+), 153 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index faf1629..6dde832 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -164,14 +164,17 @@ VIR_ENUM_IMPL(virDomainNet, VIR_DOMAIN_NET_TYPE_LAST, "internal", "direct") +VIR_ENUM_IMPL(virDomainChrChannelTarget, + VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST, + "guestfwd", + "virtio") + VIR_ENUM_IMPL(virDomainChrDevice, VIR_DOMAIN_CHR_DEVICE_TYPE_LAST, - "null", "monitor", "parallel", "serial", "console", - "guestfwd", - "virtio") + "channel") VIR_ENUM_IMPL(virDomainChr, VIR_DOMAIN_CHR_TYPE_LAST, "null", @@ -524,12 +527,19 @@ void virDomainChrDefFree(virDomainChrDefPtr def) return; switch (def->deviceType) { - case VIR_DOMAIN_CHR_DEVICE_TYPE_GUESTFWD: - VIR_FREE(def->target.addr); + case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: + switch (def->targetType) { + case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD: + VIR_FREE(def->target.addr); + break; + + case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO: + VIR_FREE(def->target.name); + break; + } break; - case VIR_DOMAIN_CHR_DEVICE_TYPE_VIRTIO: - VIR_FREE(def->target.name); + default: break; } @@ -2363,6 +2373,179 @@ error: goto cleanup; } +static int +virDomainChrDefaultTargetType(int devtype) { + + int target = -1; + + switch (devtype) { + case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: + virDomainReportError(VIR_ERR_XML_ERROR, + _("target type must be specified for %s device"), + virDomainChrDeviceTypeToString(devtype)); + break; + + case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: + case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: + case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: + default: + /* No target type yet*/ + target = 0; + break; + } + + return target; +} + +static int +virDomainChrTargetTypeFromString(int devtype, + const char *targetType) +{ + int ret = -1; + int target = 0; + + if (!targetType) { + target = virDomainChrDefaultTargetType(devtype); + goto out; + } + + switch (devtype) { + case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: + target = virDomainChrChannelTargetTypeFromString(targetType); + break; + + case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: + case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: + default: + /* No target type yet*/ + target = 0; + break; + } + +out: + ret = target; + return ret; +} + +static const char * +virDomainChrTargetTypeToString(int deviceType, + int targetType) +{ + const char *type = NULL; + + switch (deviceType) { + case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: + type = virDomainChrChannelTargetTypeToString(targetType); + break; + default: + break; + } + + return type; +} + +static int +virDomainChrDefParseTargetXML(virDomainChrDefPtr def, + xmlNodePtr cur, + int flags ATTRIBUTE_UNUSED) +{ + int ret = -1; + unsigned int port; + const char *targetType = virXMLPropString(cur, "type"); + const char *addrStr = NULL; + const char *portStr = NULL; + + if ((def->targetType = + virDomainChrTargetTypeFromString(def->deviceType, targetType)) < 0) { + goto error; + } + + switch (def->deviceType) { + case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: + switch (def->targetType) { + case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD: + addrStr = virXMLPropString(cur, "address"); + portStr = virXMLPropString(cur, "port"); + + if (addrStr == NULL) { + virDomainReportError(VIR_ERR_XML_ERROR, "%s", + _("guestfwd channel does not " + "define a target address")); + goto error; + } + + if (VIR_ALLOC(def->target.addr) < 0) { + virReportOOMError(); + goto error; + } + + if (virSocketParseAddr(addrStr, def->target.addr, 0) < 0) { + virDomainReportError(VIR_ERR_XML_ERROR, + _("%s is not a valid address"), + addrStr); + goto error; + } + + if (def->target.addr->stor.ss_family != AF_INET) { + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("guestfwd channel only supports " + "IPv4 addresses")); + goto error; + } + + if (portStr == NULL) { + virDomainReportError(VIR_ERR_XML_ERROR, "%s", + _("guestfwd channel does " + "not define a target port")); + goto error; + } + + if (virStrToLong_ui(portStr, NULL, 10, &port) < 0) { + virDomainReportError(VIR_ERR_XML_ERROR, + _("Invalid port number: %s"), + portStr); + goto error; + } + + virSocketSetPort(def->target.addr, port); + break; + + case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO: + def->target.name = virXMLPropString(cur, "name"); + break; + } + break; + + case VIR_DOMAIN_CHR_DEVICE_TYPE_MONITOR: + /* Nothing to parse */ + break; + + default: + portStr = virXMLPropString(cur, "port"); + if (portStr == NULL) { + /* Not required. It will be assigned automatically later */ + break; + } + + if (virStrToLong_ui(portStr, NULL, 10, &port) < 0) { + virDomainReportError(VIR_ERR_XML_ERROR, + _("Invalid port number: %s"), + portStr); + goto error; + } + break; + } + + + ret = 0; +error: + VIR_FREE(targetType); + VIR_FREE(addrStr); + VIR_FREE(portStr); + + return ret; +} + /* Parse the XML definition for a character device * @param node XML nodeset to parse for net definition @@ -2415,9 +2598,6 @@ virDomainChrDefParseXML(xmlNodePtr node, char *mode = NULL; char *protocol = NULL; const char *nodeName; - const char *deviceType = NULL; - const char *addrStr = NULL; - const char *portStr = NULL; virDomainChrDefPtr def; if (VIR_ALLOC(def) < 0) { @@ -2433,15 +2613,9 @@ virDomainChrDefParseXML(xmlNodePtr node, nodeName = (const char *) node->name; if ((def->deviceType = virDomainChrDeviceTypeFromString(nodeName)) < 0) { - /* channel is handled below */ - if (STRNEQ(nodeName, "channel")) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("unknown target type for character device: %s"), - nodeName); - VIR_FREE(def); - return NULL; - } - def->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_NULL; + virDomainReportError(VIR_ERR_XML_ERROR, + _("unknown character device type: %s"), + nodeName); } cur = node->children; @@ -2490,98 +2664,8 @@ virDomainChrDefParseXML(xmlNodePtr node, if (protocol == NULL) protocol = virXMLPropString(cur, "type"); } else if (xmlStrEqual(cur->name, BAD_CAST "target")) { - /* If target type isn't set yet, expect it to be set here */ - if (def->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_NULL) { - deviceType = virXMLPropString(cur, "type"); - if (deviceType == NULL) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("character device target does " - "not define a type")); - goto error; - } - if ((def->deviceType = - virDomainChrDeviceTypeFromString(deviceType)) < 0) - { - virDomainReportError(VIR_ERR_XML_ERROR, - _("unknown target type for " - "character device: %s"), - deviceType); - goto error; - } - } - - unsigned int port; - switch (def->deviceType) { - case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: - case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: - case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: - portStr = virXMLPropString(cur, "port"); - if (portStr == NULL) { - /* Not required. It will be assigned automatically - * later */ - break; - } - - if (virStrToLong_ui(portStr, NULL, 10, &port) < 0) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("Invalid port number: %s"), - portStr); - goto error; - } - break; - - case VIR_DOMAIN_CHR_DEVICE_TYPE_GUESTFWD: - addrStr = virXMLPropString(cur, "address"); - portStr = virXMLPropString(cur, "port"); - - if (addrStr == NULL) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("guestfwd channel does not " - "define a target address")); - goto error; - } - if (VIR_ALLOC(def->target.addr) < 0) { - virReportOOMError(); - goto error; - } - if (virSocketParseAddr(addrStr, def->target.addr, 0) < 0) - { - virDomainReportError(VIR_ERR_XML_ERROR, - _("%s is not a valid address"), - addrStr); - goto error; - } - - if (def->target.addr->stor.ss_family != AF_INET) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("guestfwd channel only supports " - "IPv4 addresses")); - goto error; - } - - if (portStr == NULL) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("guestfwd channel does " - "not define a target port")); - goto error; - } - if (virStrToLong_ui(portStr, NULL, 10, &port) < 0) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("Invalid port number: %s"), - portStr); - goto error; - } - virSocketSetPort(def->target.addr, port); - break; - - case VIR_DOMAIN_CHR_DEVICE_TYPE_VIRTIO: - def->target.name = virXMLPropString(cur, "name"); - break; - - default: - virDomainReportError(VIR_ERR_XML_ERROR, - _("unexpected target type type %u"), - def->deviceType); + if (virDomainChrDefParseTargetXML(def, cur, flags) < 0) { + goto error; } } } @@ -2714,9 +2798,6 @@ cleanup: VIR_FREE(connectHost); VIR_FREE(connectService); VIR_FREE(path); - VIR_FREE(deviceType); - VIR_FREE(addrStr); - VIR_FREE(portStr); return def; @@ -4496,7 +4577,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, def->channels[def->nchannels++] = chr; - if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_VIRTIO && + if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL && + chr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO && chr->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) chr->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL; @@ -5011,7 +5093,7 @@ static int virDomainDefMaybeAddVirtioSerialController(virDomainDefPtr def) for (i = 0 ; i < def->nchannels ; i++) { virDomainChrDefPtr channel = def->channels[i]; - if (channel->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_VIRTIO) { + if (channel->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO) { int idx = 0; if (channel->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL) idx = channel->info.addr.vioserial.controller; @@ -5593,28 +5675,25 @@ virDomainChrDefFormat(virBufferPtr buf, int flags) { const char *type = virDomainChrTypeToString(def->type); - const char *targetName = virDomainChrDeviceTypeToString(def->deviceType); - const char *elementName; + const char *elementName = virDomainChrDeviceTypeToString(def->deviceType); + const char *targetType = virDomainChrTargetTypeToString(def->deviceType, + def->targetType); int ret = 0; - switch (def->deviceType) { - /* channel types are in a common channel element */ - case VIR_DOMAIN_CHR_DEVICE_TYPE_GUESTFWD: - case VIR_DOMAIN_CHR_DEVICE_TYPE_VIRTIO: - elementName = "channel"; - break; - - default: - elementName = targetName; - } - if (!type) { virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected char type %d"), def->type); return -1; } + if (!elementName) { + virDomainReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected char device type %d"), + def->deviceType); + return -1; + } + /* Compat with legacy <console tty='/dev/pts/5'/> syntax */ virBufferVSprintf(buf, " <%s type='%s'", elementName, type); @@ -5693,47 +5772,57 @@ virDomainChrDefFormat(virBufferPtr buf, break; } + /* Format <target> block */ switch (def->deviceType) { - case VIR_DOMAIN_CHR_DEVICE_TYPE_GUESTFWD: - { + case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: { + if (!targetType) { + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not format channel target type")); + return -1; + } + virBufferVSprintf(buf, " <target type='%s'", targetType); + + switch (def->targetType) { + case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD: { int port = virSocketGetPort(def->target.addr); if (port < 0) { virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unable to format guestfwd port")); return -1; } + const char *addr = virSocketFormatAddr(def->target.addr); if (addr == NULL) { virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unable to format guestfwd address")); return -1; } - virBufferVSprintf(buf, - " <target type='guestfwd' address='%s' port='%d'/>\n", + + virBufferVSprintf(buf, " address='%s' port='%d'", addr, port); VIR_FREE(addr); break; } - case VIR_DOMAIN_CHR_DEVICE_TYPE_VIRTIO: - virBufferAddLit(buf, " <target type='virtio'"); - if (def->target.name) { - virBufferEscapeString(buf, " name='%s'", def->target.name); + case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO: { + if (def->target.name) { + virBufferEscapeString(buf, " name='%s'", def->target.name); + } + break; + } + } virBufferAddLit(buf, "/>\n"); break; + } - case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: - case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: - case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: - virBufferVSprintf(buf, " <target port='%d'/>\n", def->target.port); + case VIR_DOMAIN_CHR_DEVICE_TYPE_MONITOR: + /* Nothing to format */ break; default: - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected character destination type %d"), - def->deviceType); - return -1; + virBufferVSprintf(buf, " <target port='%d'/>\n", def->target.port); + break; } if (virDomainDeviceInfoIsSet(&def->info)) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 86cc02a..966607f 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -314,15 +314,20 @@ struct _virDomainNetDef { }; enum virDomainChrDeviceType { - VIR_DOMAIN_CHR_DEVICE_TYPE_NULL = 0, - VIR_DOMAIN_CHR_DEVICE_TYPE_MONITOR, + VIR_DOMAIN_CHR_DEVICE_TYPE_MONITOR = 0, VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL, VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL, VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE, - VIR_DOMAIN_CHR_DEVICE_TYPE_GUESTFWD, - VIR_DOMAIN_CHR_DEVICE_TYPE_VIRTIO, + VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL, - VIR_DOMAIN_CHR_DEVICE_TYPE_LAST + VIR_DOMAIN_CHR_DEVICE_TYPE_LAST, +}; + +enum virDomainChrChannelTargetType { + VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD = 0, + VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO, + + VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST, }; enum virDomainChrType { @@ -351,6 +356,7 @@ typedef struct _virDomainChrDef virDomainChrDef; typedef virDomainChrDef *virDomainChrDefPtr; struct _virDomainChrDef { int deviceType; + int targetType; union { int port; /* parallel, serial, console */ virSocketAddrPtr addr; /* guestfwd */ @@ -1130,6 +1136,7 @@ VIR_ENUM_DECL(virDomainControllerModel) VIR_ENUM_DECL(virDomainFS) VIR_ENUM_DECL(virDomainNet) VIR_ENUM_DECL(virDomainChrDevice) +VIR_ENUM_DECL(virDomainChrChannelTarget) VIR_ENUM_DECL(virDomainChr) VIR_ENUM_DECL(virDomainSoundModel) VIR_ENUM_DECL(virDomainMemballoonModel) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index bcca274..8873e40 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -4477,8 +4477,8 @@ int qemudBuildCommandLine(virConnectPtr conn, virDomainChrDefPtr channel = def->channels[i]; char *devstr; - switch(channel->deviceType) { - case VIR_DOMAIN_CHR_DEVICE_TYPE_GUESTFWD: + switch(channel->targetType) { + case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD: if (!(qemuCmdFlags & QEMUD_CMD_FLAG_CHARDEV) || !(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) { qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -4504,7 +4504,7 @@ int qemudBuildCommandLine(virConnectPtr conn, ADD_ARG(devstr); break; - case VIR_DOMAIN_CHR_DEVICE_TYPE_VIRTIO: + case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO: if (!(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) { qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("virtio channel requires QEMU to support -device")); -- 1.7.1.1

On Mon, Jul 26, 2010 at 03:16:23PM -0400, Cole Robinson wrote:
targetType only tracks the actual <target> format we are parsing. Currently we only fill abide this value for channel devices.
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/conf/domain_conf.c | 379 +++++++++++++++++++++++++++++------------------ src/conf/domain_conf.h | 17 ++- src/qemu/qemu_conf.c | 6 +- 3 files changed, 249 insertions(+), 153 deletions(-)
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

All <console> devices now export a <target> type attribute. QEMU defaults to 'serial', UML defaults to 'uml, xen can be either 'serial' or 'xen' depending on fullvirt. Understandably there is lots of test fallout. This will be used to differentiate between a serial vs. virtio console for QEMU. Signed-off-by: Cole Robinson <crobinso@redhat.com> --- docs/schemas/domain.rng | 30 +++++++++-- src/conf/capabilities.h | 1 + src/conf/domain_conf.c | 57 +++++++++++++++---- src/conf/domain_conf.h | 9 +++ src/qemu/qemu_conf.c | 2 + src/uml/uml_conf.c | 2 + src/xen/xen_hypervisor.c | 2 + src/xen/xend_internal.c | 1 + src/xen/xm_internal.c | 1 + tests/define-dev-segfault | 2 +- .../qemuxml2argv-console-compat.xml | 2 +- tests/qemuxml2argvdata/qemuxml2argv-serial-dev.xml | 2 +- .../qemuxml2argvdata/qemuxml2argv-serial-file.xml | 2 +- .../qemuxml2argvdata/qemuxml2argv-serial-many.xml | 2 +- tests/qemuxml2argvdata/qemuxml2argv-serial-pty.xml | 2 +- .../qemuxml2argv-serial-tcp-telnet.xml | 2 +- tests/qemuxml2argvdata/qemuxml2argv-serial-tcp.xml | 2 +- tests/qemuxml2argvdata/qemuxml2argv-serial-udp.xml | 2 +- .../qemuxml2argvdata/qemuxml2argv-serial-unix.xml | 2 +- tests/qemuxml2argvdata/qemuxml2argv-serial-vc.xml | 2 +- .../qemuxml2xmlout-console-compat-auto.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-bridge-ipaddr.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-curmem.xml | 2 +- .../sexpr2xml-disk-block-shareable.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-disk-block.xml | 2 +- .../sexpr2xml-disk-drv-blktap-qcow.xml | 2 +- .../sexpr2xml-disk-drv-blktap-raw.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-disk-file.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-kernel.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml | 2 +- .../sexpr2xml-fv-serial-tcp-telnet.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-net-bridged.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-net-e1000.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-net-routed.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-pci-devs.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-pv-bootloader.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-pv-localtime.xml | 2 +- .../sexpr2xml-pv-vfb-new-vncdisplay.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-pv-vfb-orig.xml | 2 +- .../sexpr2xmldata/sexpr2xml-pv-vfb-type-crash.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-pv.xml | 2 +- tests/vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml | 2 +- tests/vmx2xmldata/vmx2xml-serial-device.xml | 2 +- tests/vmx2xmldata/vmx2xml-serial-file.xml | 2 +- tests/vmx2xmldata/vmx2xml-serial-pipe.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-file.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-null.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-pipe.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-pty.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-stdio.xml | 2 +- .../test-fullvirt-serial-tcp-telnet.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-tcp.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-udp.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-unix.xml | 2 +- tests/xmconfigdata/test-no-source-cdrom.xml | 2 +- tests/xmconfigdata/test-paravirt-net-e1000.xml | 2 +- tests/xmconfigdata/test-paravirt-net-vifname.xml | 2 +- .../test-paravirt-new-pvfb-vncdisplay.xml | 2 +- tests/xmconfigdata/test-paravirt-new-pvfb.xml | 2 +- .../test-paravirt-old-pvfb-vncdisplay.xml | 2 +- tests/xmconfigdata/test-paravirt-old-pvfb.xml | 2 +- tests/xmconfigdata/test-pci-devs.xml | 2 +- 72 files changed, 151 insertions(+), 80 deletions(-) diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng index 2d22ce4..1421711 100644 --- a/docs/schemas/domain.rng +++ b/docs/schemas/domain.rng @@ -1202,17 +1202,37 @@ <interleave> <ref name="qemucdevSrcDef"/> <optional> - <element name="target"> - <optional> - <attribute name="port"/> - </optional> - </element> + <ref name="qemucdevTgtDef"/> </optional> <optional> <ref name="address"/> </optional> </interleave> </define> + + <define name="qemucdevConsoleTgtType"> + <attribute name="type"> + <choice> + <value>xen</value> + <value>serial</value> + <value>uml</value> + </choice> + </attribute> + </define> + + <define name="qemucdevTgtDef"> + <element name="target"> + <interleave> + <optional> + <ref name="qemucdevConsoleTgtType"/> + </optional> + <optional> + <attribute name="port"/> + </optional> + </interleave> + </element> + </define> + <define name="qemucdevSrcType"> <attribute name="type"> <choice> diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index cd96cc3..f41be1c 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -140,6 +140,7 @@ struct _virCaps { unsigned int emulatorRequired : 1; const char *defaultDiskDriverName; const char *defaultDiskDriverType; + int defaultConsoleTargetType; void *(*privateDataAllocFunc)(void); void (*privateDataFreeFunc)(void *); int (*privateDataXMLFormat)(virBufferPtr, void *); diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6dde832..c9f2d25 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -169,6 +169,12 @@ VIR_ENUM_IMPL(virDomainChrChannelTarget, "guestfwd", "virtio") +VIR_ENUM_IMPL(virDomainChrConsoleTarget, + VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST, + "serial", + "xen", + "uml") + VIR_ENUM_IMPL(virDomainChrDevice, VIR_DOMAIN_CHR_DEVICE_TYPE_LAST, "monitor", "parallel", @@ -2374,7 +2380,7 @@ error: } static int -virDomainChrDefaultTargetType(int devtype) { +virDomainChrDefaultTargetType(virCapsPtr caps, int devtype) { int target = -1; @@ -2386,6 +2392,9 @@ virDomainChrDefaultTargetType(int devtype) { break; case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: + target = caps->defaultConsoleTargetType; + break; + case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: default: @@ -2398,14 +2407,15 @@ virDomainChrDefaultTargetType(int devtype) { } static int -virDomainChrTargetTypeFromString(int devtype, +virDomainChrTargetTypeFromString(virCapsPtr caps, + int devtype, const char *targetType) { int ret = -1; int target = 0; if (!targetType) { - target = virDomainChrDefaultTargetType(devtype); + target = virDomainChrDefaultTargetType(caps, devtype); goto out; } @@ -2414,6 +2424,10 @@ virDomainChrTargetTypeFromString(int devtype, target = virDomainChrChannelTargetTypeFromString(targetType); break; + case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: + target = virDomainChrConsoleTargetTypeFromString(targetType); + /* Fall through */ + case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: default: @@ -2437,6 +2451,9 @@ virDomainChrTargetTypeToString(int deviceType, case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: type = virDomainChrChannelTargetTypeToString(targetType); break; + case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: + type = virDomainChrConsoleTargetTypeToString(targetType); + break; default: break; } @@ -2445,7 +2462,8 @@ virDomainChrTargetTypeToString(int deviceType, } static int -virDomainChrDefParseTargetXML(virDomainChrDefPtr def, +virDomainChrDefParseTargetXML(virCapsPtr caps, + virDomainChrDefPtr def, xmlNodePtr cur, int flags ATTRIBUTE_UNUSED) { @@ -2456,7 +2474,8 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr def, const char *portStr = NULL; if ((def->targetType = - virDomainChrTargetTypeFromString(def->deviceType, targetType)) < 0) { + virDomainChrTargetTypeFromString(caps, + def->deviceType, targetType)) < 0) { goto error; } @@ -2586,7 +2605,8 @@ error: * */ static virDomainChrDefPtr -virDomainChrDefParseXML(xmlNodePtr node, +virDomainChrDefParseXML(virCapsPtr caps, + xmlNodePtr node, int flags) { xmlNodePtr cur; char *type = NULL; @@ -2664,7 +2684,7 @@ virDomainChrDefParseXML(xmlNodePtr node, if (protocol == NULL) protocol = virXMLPropString(cur, "type"); } else if (xmlStrEqual(cur->name, BAD_CAST "target")) { - if (virDomainChrDefParseTargetXML(def, cur, flags) < 0) { + if (virDomainChrDefParseTargetXML(caps, def, cur, flags) < 0) { goto error; } } @@ -4504,7 +4524,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainChrDefPtr chr = virDomainChrDefParseXML(nodes[i], + virDomainChrDefPtr chr = virDomainChrDefParseXML(caps, + nodes[i], flags); if (!chr) goto error; @@ -4523,7 +4544,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainChrDefPtr chr = virDomainChrDefParseXML(nodes[i], + virDomainChrDefPtr chr = virDomainChrDefParseXML(caps, + nodes[i], flags); if (!chr) goto error; @@ -4534,7 +4556,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, VIR_FREE(nodes); if ((node = virXPathNode("./devices/console[1]", ctxt)) != NULL) { - virDomainChrDefPtr chr = virDomainChrDefParseXML(node, + virDomainChrDefPtr chr = virDomainChrDefParseXML(caps, + node, flags); if (!chr) goto error; @@ -4570,7 +4593,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainChrDefPtr chr = virDomainChrDefParseXML(nodes[i], + virDomainChrDefPtr chr = virDomainChrDefParseXML(caps, + nodes[i], flags); if (!chr) goto error; @@ -5820,8 +5844,17 @@ virDomainChrDefFormat(virBufferPtr buf, /* Nothing to format */ break; + case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: + virBufferVSprintf(buf, + " <target type='%s' port='%d'/>\n", + virDomainChrTargetTypeToString(def->deviceType, + def->targetType), + def->target.port); + break; + default: - virBufferVSprintf(buf, " <target port='%d'/>\n", def->target.port); + virBufferVSprintf(buf, " <target port='%d'/>\n", + def->target.port); break; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 966607f..c82dc60 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -330,6 +330,14 @@ enum virDomainChrChannelTargetType { VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST, }; +enum virDomainChrConsoleTargetType { + VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL = 0, + VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN, + VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML, + + VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST, +}; + enum virDomainChrType { VIR_DOMAIN_CHR_TYPE_NULL, VIR_DOMAIN_CHR_TYPE_VC, @@ -1137,6 +1145,7 @@ VIR_ENUM_DECL(virDomainFS) VIR_ENUM_DECL(virDomainNet) VIR_ENUM_DECL(virDomainChrDevice) VIR_ENUM_DECL(virDomainChrChannelTarget) +VIR_ENUM_DECL(virDomainChrConsoleTarget) VIR_ENUM_DECL(virDomainChr) VIR_ENUM_DECL(virDomainSoundModel) VIR_ENUM_DECL(virDomainMemballoonModel) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 8873e40..3f77e6a 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1137,6 +1137,8 @@ virCapsPtr qemudCapsInit(virCapsPtr old_caps) { /* QEMU Requires an emulator in the XML */ virCapabilitiesSetEmulatorRequired(caps); + caps->defaultConsoleTargetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; + return caps; no_memory: diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c index ea40efb..bef8c38 100644 --- a/src/uml/uml_conf.c +++ b/src/uml/uml_conf.c @@ -97,6 +97,8 @@ virCapsPtr umlCapsInit(void) { NULL) == NULL) goto error; + caps->defaultConsoleTargetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML; + return caps; error: diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c index ae17c60..67d0f4b 100644 --- a/src/xen/xen_hypervisor.c +++ b/src/xen/xen_hypervisor.c @@ -2342,6 +2342,8 @@ xenHypervisorBuildCapabilities(virConnectPtr conn, } } + caps->defaultConsoleTargetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; + return caps; no_memory: diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c index a492231..fad5ce8 100644 --- a/src/xen/xend_internal.c +++ b/src/xen/xend_internal.c @@ -2367,6 +2367,7 @@ xenDaemonParseSxpr(virConnectPtr conn, if (!(def->console = xenDaemonParseSxprChar("pty", tty))) goto error; def->console->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE; + def->console->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; } VIR_FREE(tty); diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c index 4230504..20b828d 100644 --- a/src/xen/xm_internal.c +++ b/src/xen/xm_internal.c @@ -1441,6 +1441,7 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) { if (!(def->console = xenDaemonParseSxprChar("pty", NULL))) goto cleanup; def->console->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE; + def->console->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; } if (hvm) { diff --git a/tests/define-dev-segfault b/tests/define-dev-segfault index 7a9a7b6..19d4e67 100755 --- a/tests/define-dev-segfault +++ b/tests/define-dev-segfault @@ -55,7 +55,7 @@ cat <<\EOF > D.xml || fail=1 <target port='2'/> </parallel> <console type='pty'> - <target port='0'/> + <target type='serial' port='0'/> </console> <sound model='pcspk'/> <sound model='es1370'/> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-compat.xml b/tests/qemuxml2argvdata/qemuxml2argv-console-compat.xml index 611ddb8..9591c87 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-console-compat.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-console-compat.xml @@ -24,7 +24,7 @@ <target port='0'/> </serial> <console type='pty'> - <target port='0'/> + <target type='serial' port='0'/> </console> <memballoon model='virtio'/> </devices> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-dev.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-dev.xml index 5d24986..cc0ab43 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-serial-dev.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-dev.xml @@ -26,7 +26,7 @@ </serial> <console type='dev'> <source path='/dev/ttyS2'/> - <target port='0'/> + <target type='serial' port='0'/> </console> <memballoon model='virtio'/> </devices> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-file.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-file.xml index 98bc4ef..3e60e98 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-serial-file.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-file.xml @@ -26,7 +26,7 @@ </serial> <console type='file'> <source path='/tmp/serial.log'/> - <target port='0'/> + <target type='serial' port='0'/> </console> <memballoon model='virtio'/> </devices> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-many.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-many.xml index b121c5c..1d042f1 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-serial-many.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-many.xml @@ -28,7 +28,7 @@ <target port='1'/> </serial> <console type='pty'> - <target port='0'/> + <target type='serial' port='0'/> </console> <memballoon model='virtio'/> </devices> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-pty.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-pty.xml index 611ddb8..9591c87 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-serial-pty.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-pty.xml @@ -24,7 +24,7 @@ <target port='0'/> </serial> <console type='pty'> - <target port='0'/> + <target type='serial' port='0'/> </console> <memballoon model='virtio'/> </devices> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-telnet.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-telnet.xml index 5aeceb0..5bf6a08 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-telnet.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-telnet.xml @@ -28,7 +28,7 @@ <console type='tcp'> <source mode='bind' host='127.0.0.1' service='9999'/> <protocol type='telnet'/> - <target port='0'/> + <target type='serial' port='0'/> </console> <memballoon model='virtio'/> </devices> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp.xml index 286417e..304792e 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp.xml @@ -28,7 +28,7 @@ <console type='tcp'> <source mode='connect' host='127.0.0.1' service='9999'/> <protocol type='raw'/> - <target port='0'/> + <target type='serial' port='0'/> </console> <memballoon model='virtio'/> </devices> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-udp.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-udp.xml index 2c44738..e4fe4fd 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-serial-udp.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-udp.xml @@ -28,7 +28,7 @@ <console type='udp'> <source mode='bind' host='127.0.0.1' service='9999'/> <source mode='connect' host='127.0.0.1' service='9998'/> - <target port='0'/> + <target type='serial' port='0'/> </console> <memballoon model='virtio'/> </devices> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-unix.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-unix.xml index 2c07e94..61dff3f 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-serial-unix.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-unix.xml @@ -26,7 +26,7 @@ </serial> <console type='unix'> <source mode='connect' path='/tmp/serial.sock'/> - <target port='0'/> + <target type='serial' port='0'/> </console> <memballoon model='virtio'/> </devices> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-vc.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-vc.xml index 5b39736..36bd622 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-serial-vc.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-vc.xml @@ -24,7 +24,7 @@ <target port='0'/> </serial> <console type='vc'> - <target port='0'/> + <target type='serial' port='0'/> </console> <memballoon model='virtio'/> </devices> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml index 611ddb8..9591c87 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml @@ -24,7 +24,7 @@ <target port='0'/> </serial> <console type='pty'> - <target port='0'/> + <target type='serial' port='0'/> </console> <memballoon model='virtio'/> </devices> diff --git a/tests/sexpr2xmldata/sexpr2xml-bridge-ipaddr.xml b/tests/sexpr2xmldata/sexpr2xml-bridge-ipaddr.xml index 14dc37c..bfac0f4 100644 --- a/tests/sexpr2xmldata/sexpr2xml-bridge-ipaddr.xml +++ b/tests/sexpr2xmldata/sexpr2xml-bridge-ipaddr.xml @@ -28,7 +28,7 @@ <target dev='vif6.0'/> </interface> <console type='pty'> - <target port='0'/> + <target type='xen' port='0'/> </console> </devices> </domain> diff --git a/tests/sexpr2xmldata/sexpr2xml-curmem.xml b/tests/sexpr2xmldata/sexpr2xml-curmem.xml index fb1217b..6be4d5d 100644 --- a/tests/sexpr2xmldata/sexpr2xml-curmem.xml +++ b/tests/sexpr2xmldata/sexpr2xml-curmem.xml @@ -28,7 +28,7 @@ <target dev='vif5.0'/> </interface> <console type='pty'> - <target port='0'/> + <target type='xen' port='0'/> </console> <input type='mouse' bus='xen'/> <graphics type='vnc' port='-1' autoport='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-disk-block-shareable.xml b/tests/sexpr2xmldata/sexpr2xml-disk-block-shareable.xml index f164c4d..d7e3054 100644 --- a/tests/sexpr2xmldata/sexpr2xml-disk-block-shareable.xml +++ b/tests/sexpr2xmldata/sexpr2xml-disk-block-shareable.xml @@ -26,7 +26,7 @@ <target dev='vif6.0'/> </interface> <console type='pty'> - <target port='0'/> + <target type='xen' port='0'/> </console> </devices> </domain> diff --git a/tests/sexpr2xmldata/sexpr2xml-disk-block.xml b/tests/sexpr2xmldata/sexpr2xml-disk-block.xml index 9eb116c..d9d7552 100644 --- a/tests/sexpr2xmldata/sexpr2xml-disk-block.xml +++ b/tests/sexpr2xmldata/sexpr2xml-disk-block.xml @@ -21,7 +21,7 @@ <target dev='xvda' bus='xen'/> </disk> <console type='pty'> - <target port='0'/> + <target type='xen' port='0'/> </console> </devices> </domain> diff --git a/tests/sexpr2xmldata/sexpr2xml-disk-drv-blktap-qcow.xml b/tests/sexpr2xmldata/sexpr2xml-disk-drv-blktap-qcow.xml index 4c56a72..04824ba 100644 --- a/tests/sexpr2xmldata/sexpr2xml-disk-drv-blktap-qcow.xml +++ b/tests/sexpr2xmldata/sexpr2xml-disk-drv-blktap-qcow.xml @@ -21,7 +21,7 @@ <target dev='xvda' bus='xen'/> </disk> <console type='pty'> - <target port='0'/> + <target type='xen' port='0'/> </console> </devices> </domain> diff --git a/tests/sexpr2xmldata/sexpr2xml-disk-drv-blktap-raw.xml b/tests/sexpr2xmldata/sexpr2xml-disk-drv-blktap-raw.xml index 4c8273f..3e935db 100644 --- a/tests/sexpr2xmldata/sexpr2xml-disk-drv-blktap-raw.xml +++ b/tests/sexpr2xmldata/sexpr2xml-disk-drv-blktap-raw.xml @@ -21,7 +21,7 @@ <target dev='xvda' bus='xen'/> </disk> <console type='pty'> - <target port='0'/> + <target type='xen' port='0'/> </console> </devices> </domain> diff --git a/tests/sexpr2xmldata/sexpr2xml-disk-file.xml b/tests/sexpr2xmldata/sexpr2xml-disk-file.xml index 10cbc2d..8aa3214 100644 --- a/tests/sexpr2xmldata/sexpr2xml-disk-file.xml +++ b/tests/sexpr2xmldata/sexpr2xml-disk-file.xml @@ -21,7 +21,7 @@ <target dev='xvda' bus='xen'/> </disk> <console type='pty'> - <target port='0'/> + <target type='xen' port='0'/> </console> </devices> </domain> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml b/tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml index 6efe8de..3f501e7 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml @@ -39,7 +39,7 @@ <target port='0'/> </serial> <console type='pty'> - <target port='0'/> + <target type='serial' port='0'/> </console> <input type='tablet' bus='usb'/> <input type='mouse' bus='ps2'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-kernel.xml b/tests/sexpr2xmldata/sexpr2xml-fv-kernel.xml index 2809867..bd38a25 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-kernel.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-kernel.xml @@ -25,7 +25,7 @@ <target port='0'/> </serial> <console type='pty'> - <target port='0'/> + <target type='serial' port='0'/> </console> </devices> </domain> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml index 5a6b414..db010ad 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml @@ -41,7 +41,7 @@ </serial> <console type='file'> <source path='/tmp/serial.log'/> - <target port='0'/> + <target type='serial' port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='5901' autoport='no'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml index f496433..faeed77 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml @@ -39,7 +39,7 @@ <target port='0'/> </serial> <console type='null'> - <target port='0'/> + <target type='serial' port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='5901' autoport='no'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml index 97d4528..0967ac7 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml @@ -41,7 +41,7 @@ </serial> <console type='pipe'> <source path='/tmp/serial.pipe'/> - <target port='0'/> + <target type='serial' port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='5901' autoport='no'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml index 06da049..3773d3b 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml @@ -39,7 +39,7 @@ <target port='0'/> </serial> <console type='pty'> - <target port='0'/> + <target type='serial' port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='5901' autoport='no'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml index 5f89a75..d46df09 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml @@ -39,7 +39,7 @@ <target port='0'/> </serial> <console type='stdio'> - <target port='0'/> + <target type='serial' port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='5901' autoport='no'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp-telnet.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp-telnet.xml index e6cb357..34f25ac 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp-telnet.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp-telnet.xml @@ -43,7 +43,7 @@ <console type='tcp'> <source mode='bind' host='localhost' service='9999'/> <protocol type='telnet'/> - <target port='0'/> + <target type='serial' port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='5901' autoport='no'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml index 2eac19c..6c69214 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml @@ -43,7 +43,7 @@ <console type='tcp'> <source mode='bind' host='localhost' service='9999'/> <protocol type='raw'/> - <target port='0'/> + <target type='serial' port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='5901' autoport='no'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml index 9a3a0e2..bcc20dd 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml @@ -43,7 +43,7 @@ <console type='udp'> <source mode='bind' host='localhost' service='9999'/> <source mode='connect' host='localhost' service='9998'/> - <target port='0'/> + <target type='serial' port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='5901' autoport='no'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml index e026cf8..93f20fa 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml @@ -41,7 +41,7 @@ </serial> <console type='unix'> <source mode='bind' path='/tmp/serial.sock'/> - <target port='0'/> + <target type='serial' port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='5901' autoport='no'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-net-bridged.xml b/tests/sexpr2xmldata/sexpr2xml-net-bridged.xml index 717ec79..a1249ba 100644 --- a/tests/sexpr2xmldata/sexpr2xml-net-bridged.xml +++ b/tests/sexpr2xmldata/sexpr2xml-net-bridged.xml @@ -27,7 +27,7 @@ <target dev='vif6.0'/> </interface> <console type='pty'> - <target port='0'/> + <target type='xen' port='0'/> </console> </devices> </domain> diff --git a/tests/sexpr2xmldata/sexpr2xml-net-e1000.xml b/tests/sexpr2xmldata/sexpr2xml-net-e1000.xml index be77a82..91fd656 100644 --- a/tests/sexpr2xmldata/sexpr2xml-net-e1000.xml +++ b/tests/sexpr2xmldata/sexpr2xml-net-e1000.xml @@ -28,7 +28,7 @@ <model type='e1000'/> </interface> <console type='pty'> - <target port='0'/> + <target type='xen' port='0'/> </console> </devices> </domain> diff --git a/tests/sexpr2xmldata/sexpr2xml-net-routed.xml b/tests/sexpr2xmldata/sexpr2xml-net-routed.xml index 07a08db..a519551 100644 --- a/tests/sexpr2xmldata/sexpr2xml-net-routed.xml +++ b/tests/sexpr2xmldata/sexpr2xml-net-routed.xml @@ -27,7 +27,7 @@ <target dev='vif6.0'/> </interface> <console type='pty'> - <target port='0'/> + <target type='xen' port='0'/> </console> </devices> </domain> diff --git a/tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml b/tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml index db34474..5a82775 100644 --- a/tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml +++ b/tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml @@ -38,7 +38,7 @@ <target port='0'/> </serial> <console type='pty'> - <target port='0'/> + <target type='serial' port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-pci-devs.xml b/tests/sexpr2xmldata/sexpr2xml-pci-devs.xml index 40e12c0..fe0ecb6 100644 --- a/tests/sexpr2xmldata/sexpr2xml-pci-devs.xml +++ b/tests/sexpr2xmldata/sexpr2xml-pci-devs.xml @@ -21,7 +21,7 @@ <target dev='xvda' bus='xen'/> </disk> <console type='pty'> - <target port='0'/> + <target type='xen' port='0'/> </console> <hostdev mode='subsystem' type='pci' managed='no'> <source> diff --git a/tests/sexpr2xmldata/sexpr2xml-pv-bootloader.xml b/tests/sexpr2xmldata/sexpr2xml-pv-bootloader.xml index eddf32f..920c058 100644 --- a/tests/sexpr2xmldata/sexpr2xml-pv-bootloader.xml +++ b/tests/sexpr2xmldata/sexpr2xml-pv-bootloader.xml @@ -20,7 +20,7 @@ <target dev='xvda' bus='xen'/> </disk> <console type='pty'> - <target port='0'/> + <target type='xen' port='0'/> </console> </devices> </domain> diff --git a/tests/sexpr2xmldata/sexpr2xml-pv-localtime.xml b/tests/sexpr2xmldata/sexpr2xml-pv-localtime.xml index 480327d..6466192 100644 --- a/tests/sexpr2xmldata/sexpr2xml-pv-localtime.xml +++ b/tests/sexpr2xmldata/sexpr2xml-pv-localtime.xml @@ -21,7 +21,7 @@ <target dev='xvda' bus='xen'/> </disk> <console type='pty'> - <target port='0'/> + <target type='xen' port='0'/> </console> </devices> </domain> diff --git a/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new-vncdisplay.xml b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new-vncdisplay.xml index 40302d0..0914bc9 100644 --- a/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new-vncdisplay.xml +++ b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new-vncdisplay.xml @@ -21,7 +21,7 @@ <target dev='xvda' bus='xen'/> </disk> <console type='pty'> - <target port='0'/> + <target type='xen' port='0'/> </console> <input type='mouse' bus='xen'/> <graphics type='vnc' port='5925' autoport='no' listen='0.0.0.0' keymap='ja'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.xml b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.xml index 9a0ad1f..0657fba 100644 --- a/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.xml +++ b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.xml @@ -21,7 +21,7 @@ <target dev='xvda' bus='xen'/> </disk> <console type='pty'> - <target port='0'/> + <target type='xen' port='0'/> </console> <input type='mouse' bus='xen'/> <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0' keymap='ja'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-pv-vfb-orig.xml b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-orig.xml index 9a0ad1f..0657fba 100644 --- a/tests/sexpr2xmldata/sexpr2xml-pv-vfb-orig.xml +++ b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-orig.xml @@ -21,7 +21,7 @@ <target dev='xvda' bus='xen'/> </disk> <console type='pty'> - <target port='0'/> + <target type='xen' port='0'/> </console> <input type='mouse' bus='xen'/> <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0' keymap='ja'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-pv-vfb-type-crash.xml b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-type-crash.xml index 19c7ab8..766c78d 100644 --- a/tests/sexpr2xmldata/sexpr2xml-pv-vfb-type-crash.xml +++ b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-type-crash.xml @@ -26,7 +26,7 @@ <target dev='vif1.0'/> </interface> <console type='pty'> - <target port='0'/> + <target type='xen' port='0'/> </console> <input type='mouse' bus='xen'/> <graphics type='vnc' port='-1' autoport='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-pv.xml b/tests/sexpr2xmldata/sexpr2xml-pv.xml index 10cbc2d..8aa3214 100644 --- a/tests/sexpr2xmldata/sexpr2xml-pv.xml +++ b/tests/sexpr2xmldata/sexpr2xml-pv.xml @@ -21,7 +21,7 @@ <target dev='xvda' bus='xen'/> </disk> <console type='pty'> - <target port='0'/> + <target type='xen' port='0'/> </console> </devices> </domain> diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml index 5b8fbb9..4238882 100644 --- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml @@ -36,7 +36,7 @@ </parallel> <console type='file'> <source path='[498076b2-02796c1a-ef5b-000ae484a6a3] virtMonServ1/serial1.file'/> - <target port='0'/> + <target type='serial' port='0'/> </console> </devices> </domain> diff --git a/tests/vmx2xmldata/vmx2xml-serial-device.xml b/tests/vmx2xmldata/vmx2xml-serial-device.xml index 83e1ce9..c9f00eb 100644 --- a/tests/vmx2xmldata/vmx2xml-serial-device.xml +++ b/tests/vmx2xmldata/vmx2xml-serial-device.xml @@ -17,7 +17,7 @@ </serial> <console type='dev'> <source path='/dev/ttyS0'/> - <target port='0'/> + <target type='serial' port='0'/> </console> </devices> </domain> diff --git a/tests/vmx2xmldata/vmx2xml-serial-file.xml b/tests/vmx2xmldata/vmx2xml-serial-file.xml index 95816e0..21b6263 100644 --- a/tests/vmx2xmldata/vmx2xml-serial-file.xml +++ b/tests/vmx2xmldata/vmx2xml-serial-file.xml @@ -17,7 +17,7 @@ </serial> <console type='file'> <source path='[datastore] directory/serial0.file'/> - <target port='0'/> + <target type='serial' port='0'/> </console> </devices> </domain> diff --git a/tests/vmx2xmldata/vmx2xml-serial-pipe.xml b/tests/vmx2xmldata/vmx2xml-serial-pipe.xml index 38e69a6..cf8a797 100644 --- a/tests/vmx2xmldata/vmx2xml-serial-pipe.xml +++ b/tests/vmx2xmldata/vmx2xml-serial-pipe.xml @@ -17,7 +17,7 @@ </serial> <console type='pipe'> <source path='serial0.pipe'/> - <target port='0'/> + <target type='serial' port='0'/> </console> </devices> </domain> diff --git a/tests/xmconfigdata/test-fullvirt-serial-file.xml b/tests/xmconfigdata/test-fullvirt-serial-file.xml index a601ee2..02ecaa2 100644 --- a/tests/xmconfigdata/test-fullvirt-serial-file.xml +++ b/tests/xmconfigdata/test-fullvirt-serial-file.xml @@ -42,7 +42,7 @@ </serial> <console type='file'> <source path='/tmp/serial.log'/> - <target port='0'/> + <target type='serial' port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/> diff --git a/tests/xmconfigdata/test-fullvirt-serial-null.xml b/tests/xmconfigdata/test-fullvirt-serial-null.xml index 94b4034..542b779 100644 --- a/tests/xmconfigdata/test-fullvirt-serial-null.xml +++ b/tests/xmconfigdata/test-fullvirt-serial-null.xml @@ -40,7 +40,7 @@ <target port='0'/> </serial> <console type='null'> - <target port='0'/> + <target type='serial' port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/> diff --git a/tests/xmconfigdata/test-fullvirt-serial-pipe.xml b/tests/xmconfigdata/test-fullvirt-serial-pipe.xml index 217806a..6150168 100644 --- a/tests/xmconfigdata/test-fullvirt-serial-pipe.xml +++ b/tests/xmconfigdata/test-fullvirt-serial-pipe.xml @@ -42,7 +42,7 @@ </serial> <console type='pipe'> <source path='/tmp/serial.pipe'/> - <target port='0'/> + <target type='serial' port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/> diff --git a/tests/xmconfigdata/test-fullvirt-serial-pty.xml b/tests/xmconfigdata/test-fullvirt-serial-pty.xml index 4576087..53e6d4f 100644 --- a/tests/xmconfigdata/test-fullvirt-serial-pty.xml +++ b/tests/xmconfigdata/test-fullvirt-serial-pty.xml @@ -40,7 +40,7 @@ <target port='0'/> </serial> <console type='pty'> - <target port='0'/> + <target type='serial' port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/> diff --git a/tests/xmconfigdata/test-fullvirt-serial-stdio.xml b/tests/xmconfigdata/test-fullvirt-serial-stdio.xml index 8717799..b540481 100644 --- a/tests/xmconfigdata/test-fullvirt-serial-stdio.xml +++ b/tests/xmconfigdata/test-fullvirt-serial-stdio.xml @@ -40,7 +40,7 @@ <target port='0'/> </serial> <console type='stdio'> - <target port='0'/> + <target type='serial' port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/> diff --git a/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.xml b/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.xml index 52c433e..31c5de8 100644 --- a/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.xml +++ b/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.xml @@ -44,7 +44,7 @@ <console type='tcp'> <source mode='bind' host='127.0.0.1' service='9999'/> <protocol type='telnet'/> - <target port='0'/> + <target type='serial' port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/> diff --git a/tests/xmconfigdata/test-fullvirt-serial-tcp.xml b/tests/xmconfigdata/test-fullvirt-serial-tcp.xml index 062cf54..3b2994a 100644 --- a/tests/xmconfigdata/test-fullvirt-serial-tcp.xml +++ b/tests/xmconfigdata/test-fullvirt-serial-tcp.xml @@ -44,7 +44,7 @@ <console type='tcp'> <source mode='connect' host='127.0.0.1' service='7777'/> <protocol type='raw'/> - <target port='0'/> + <target type='serial' port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/> diff --git a/tests/xmconfigdata/test-fullvirt-serial-udp.xml b/tests/xmconfigdata/test-fullvirt-serial-udp.xml index 7871310..66b3824 100644 --- a/tests/xmconfigdata/test-fullvirt-serial-udp.xml +++ b/tests/xmconfigdata/test-fullvirt-serial-udp.xml @@ -44,7 +44,7 @@ <console type='udp'> <source mode='bind' host='0.0.0.0' service='99998'/> <source mode='connect' host='127.0.0.1' service='9999'/> - <target port='0'/> + <target type='serial' port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/> diff --git a/tests/xmconfigdata/test-fullvirt-serial-unix.xml b/tests/xmconfigdata/test-fullvirt-serial-unix.xml index e517b33..1ffe6be 100644 --- a/tests/xmconfigdata/test-fullvirt-serial-unix.xml +++ b/tests/xmconfigdata/test-fullvirt-serial-unix.xml @@ -42,7 +42,7 @@ </serial> <console type='unix'> <source mode='bind' path='/tmp/serial.sock'/> - <target port='0'/> + <target type='serial' port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/> diff --git a/tests/xmconfigdata/test-no-source-cdrom.xml b/tests/xmconfigdata/test-no-source-cdrom.xml index 9b1dd01..4114510 100644 --- a/tests/xmconfigdata/test-no-source-cdrom.xml +++ b/tests/xmconfigdata/test-no-source-cdrom.xml @@ -39,7 +39,7 @@ <target port='0'/> </serial> <console type='pty'> - <target port='0'/> + <target type='serial' port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'/> diff --git a/tests/xmconfigdata/test-paravirt-net-e1000.xml b/tests/xmconfigdata/test-paravirt-net-e1000.xml index bb8308b..d709e69 100644 --- a/tests/xmconfigdata/test-paravirt-net-e1000.xml +++ b/tests/xmconfigdata/test-paravirt-net-e1000.xml @@ -25,7 +25,7 @@ <model type='e1000'/> </interface> <console type='pty'> - <target port='0'/> + <target type='xen' port='0'/> </console> <input type='mouse' bus='xen'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/> diff --git a/tests/xmconfigdata/test-paravirt-net-vifname.xml b/tests/xmconfigdata/test-paravirt-net-vifname.xml index 9814577..b6c4739 100644 --- a/tests/xmconfigdata/test-paravirt-net-vifname.xml +++ b/tests/xmconfigdata/test-paravirt-net-vifname.xml @@ -26,7 +26,7 @@ <model type='e1000'/> </interface> <console type='pty'> - <target port='0'/> + <target type='xen' port='0'/> </console> <input type='mouse' bus='xen'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/> diff --git a/tests/xmconfigdata/test-paravirt-new-pvfb-vncdisplay.xml b/tests/xmconfigdata/test-paravirt-new-pvfb-vncdisplay.xml index eb95fd4..39325ea 100644 --- a/tests/xmconfigdata/test-paravirt-new-pvfb-vncdisplay.xml +++ b/tests/xmconfigdata/test-paravirt-new-pvfb-vncdisplay.xml @@ -24,7 +24,7 @@ <script path='vif-bridge'/> </interface> <console type='pty'> - <target port='0'/> + <target type='xen' port='0'/> </console> <input type='mouse' bus='xen'/> <graphics type='vnc' port='5925' autoport='no' listen='127.0.0.1' passwd='123poi'/> diff --git a/tests/xmconfigdata/test-paravirt-new-pvfb.xml b/tests/xmconfigdata/test-paravirt-new-pvfb.xml index f359ba1..40c79cb 100644 --- a/tests/xmconfigdata/test-paravirt-new-pvfb.xml +++ b/tests/xmconfigdata/test-paravirt-new-pvfb.xml @@ -24,7 +24,7 @@ <script path='vif-bridge'/> </interface> <console type='pty'> - <target port='0'/> + <target type='xen' port='0'/> </console> <input type='mouse' bus='xen'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/> diff --git a/tests/xmconfigdata/test-paravirt-old-pvfb-vncdisplay.xml b/tests/xmconfigdata/test-paravirt-old-pvfb-vncdisplay.xml index eb95fd4..39325ea 100644 --- a/tests/xmconfigdata/test-paravirt-old-pvfb-vncdisplay.xml +++ b/tests/xmconfigdata/test-paravirt-old-pvfb-vncdisplay.xml @@ -24,7 +24,7 @@ <script path='vif-bridge'/> </interface> <console type='pty'> - <target port='0'/> + <target type='xen' port='0'/> </console> <input type='mouse' bus='xen'/> <graphics type='vnc' port='5925' autoport='no' listen='127.0.0.1' passwd='123poi'/> diff --git a/tests/xmconfigdata/test-paravirt-old-pvfb.xml b/tests/xmconfigdata/test-paravirt-old-pvfb.xml index f359ba1..40c79cb 100644 --- a/tests/xmconfigdata/test-paravirt-old-pvfb.xml +++ b/tests/xmconfigdata/test-paravirt-old-pvfb.xml @@ -24,7 +24,7 @@ <script path='vif-bridge'/> </interface> <console type='pty'> - <target port='0'/> + <target type='xen' port='0'/> </console> <input type='mouse' bus='xen'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/> diff --git a/tests/xmconfigdata/test-pci-devs.xml b/tests/xmconfigdata/test-pci-devs.xml index 09456d0..74bc227 100644 --- a/tests/xmconfigdata/test-pci-devs.xml +++ b/tests/xmconfigdata/test-pci-devs.xml @@ -39,7 +39,7 @@ <target port='0'/> </serial> <console type='pty'> - <target port='0'/> + <target type='serial' port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'/> -- 1.7.1.1

On Mon, Jul 26, 2010 at 03:16:24PM -0400, Cole Robinson wrote:
All <console> devices now export a <target> type attribute. QEMU defaults to 'serial', UML defaults to 'uml, xen can be either 'serial' or 'xen' depending on fullvirt. Understandably there is lots of test fallout.
This will be used to differentiate between a serial vs. virtio console for QEMU.
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

Enable specifying a virtio console device with: <console type='pty'> <target type='virtio'/> </console> Signed-off-by: Cole Robinson <crobinso@redhat.com> --- docs/formatdomain.html.in | 18 +++++++- docs/schemas/domain.rng | 5 ++- src/conf/domain_conf.c | 32 +++++++++++---- src/conf/domain_conf.h | 1 + src/libvirt_private.syms | 1 + src/qemu/qemu_conf.c | 44 +++++++++++++++++++- src/qemu/qemu_driver.c | 2 + .../qemuxml2argv-console-virtio.args | 1 + .../qemuxml2argv-console-virtio.xml | 27 ++++++++++++ tests/qemuxml2argvtest.c | 2 + .../qemuxml2xmlout-console-virtio.xml | 29 +++++++++++++ tests/qemuxml2xmltest.c | 1 + 12 files changed, 151 insertions(+), 12 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-virtio.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-virtio.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 8714a14..b23a1c2 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1124,8 +1124,16 @@ qemu-kvm -net nic,model=? /dev/null <p> This represents the primary console. This can be the paravirtualized - console with Xen guests, or duplicates the primary serial port for fully - virtualized guests without a paravirtualized console. + console with Xen guests, virtio console for QEMU/KVM, or duplicates + the primary serial port for fully virtualized guests without a + paravirtualized console. + </p> + + <p> + A virtio console device is exposed in the + guest as /dev/hvc[0-7] (for more information, see + <a href="http://fedoraproject.org/wiki/Features/VirtioSerial">http://fedoraproject.org/wiki/Features/VirtioSerial</a>) + <span class="since">Since 0.8.3</span> </p> <pre> @@ -1135,6 +1143,12 @@ qemu-kvm -net nic,model=? /dev/null <source path='/dev/pts/4'/> <target port='0'/> </console> + + <!-- KVM virtio console --> + <console type='pty'> + <source path='/dev/pts/5'/> + <target type='virtio' port='0'/> + </console> </devices> ...</pre> diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng index 1421711..833c018 100644 --- a/docs/schemas/domain.rng +++ b/docs/schemas/domain.rng @@ -1216,6 +1216,7 @@ <value>xen</value> <value>serial</value> <value>uml</value> + <value>virtio</value> </choice> </attribute> </define> @@ -1292,7 +1293,9 @@ </optional> <empty/> </group> - <ref name="qemucdev"/> + <choice> + <ref name="qemucdev"/> + </choice> </choice> </element> </define> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c9f2d25..1ff189c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -173,7 +173,8 @@ VIR_ENUM_IMPL(virDomainChrConsoleTarget, VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST, "serial", "xen", - "uml") + "uml", + "virtio") VIR_ENUM_IMPL(virDomainChrDevice, VIR_DOMAIN_CHR_DEVICE_TYPE_LAST, "monitor", @@ -2426,13 +2427,12 @@ virDomainChrTargetTypeFromString(virCapsPtr caps, case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: target = virDomainChrConsoleTargetTypeFromString(targetType); - /* Fall through */ + break; case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: default: /* No target type yet*/ - target = 0; break; } @@ -4567,7 +4567,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, * For HVM console actually created a serial device * while for non-HVM it was a parvirt console */ - if (STREQ(def->os.type, "hvm")) { + if (STREQ(def->os.type, "hvm") && + chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL) { if (def->nserials != 0) { virDomainChrDefFree(chr); } else { @@ -5111,7 +5112,7 @@ static int virDomainDefAddDiskControllersForType(virDomainDefPtr def, static int virDomainDefMaybeAddVirtioSerialController(virDomainDefPtr def) { - /* Look for any virtio serial device */ + /* Look for any virtio serial or virtio console devs */ int i; for (i = 0 ; i < def->nchannels ; i++) { @@ -5128,6 +5129,21 @@ static int virDomainDefMaybeAddVirtioSerialController(virDomainDefPtr def) } } + if (def->console) { + virDomainChrDefPtr console = def->console; + + if (console->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO) { + int idx = 0; + if (console->info.type == + VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL) + idx = console->info.addr.vioserial.controller; + + if (virDomainDefMaybeAddController(def, + VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL, idx) < 0) + return -1; + } + } + return 0; } @@ -5722,14 +5738,14 @@ virDomainChrDefFormat(virBufferPtr buf, virBufferVSprintf(buf, " <%s type='%s'", elementName, type); if (def->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && + def->target.port == 0 && def->type == VIR_DOMAIN_CHR_TYPE_PTY && !(flags & VIR_DOMAIN_XML_INACTIVE) && def->data.file.path) { - virBufferEscapeString(buf, " tty='%s'>\n", + virBufferEscapeString(buf, " tty='%s'", def->data.file.path); - } else { - virBufferAddLit(buf, ">\n"); } + virBufferAddLit(buf, ">\n"); switch (def->type) { case VIR_DOMAIN_CHR_TYPE_NULL: diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index c82dc60..fe09dbc 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -334,6 +334,7 @@ enum virDomainChrConsoleTargetType { VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL = 0, VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN, VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML, + VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO, VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST, }; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6b83cb9..b5944a7 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -228,6 +228,7 @@ virDomainSnapshotAssignDef; virDomainObjAssignDef; virDomainChrDefForeach; virDomainDiskDefForeachPath; +virDomainChrConsoleTargetTypeToString; # domain_event.h diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 3f77e6a..f79775b 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -2028,6 +2028,10 @@ qemuAssignDeviceAliases(virDomainDefPtr def, unsigned long long qemuCmdFlags) if (virAsprintf(&def->channels[i]->info.alias, "channel%d", i) < 0) goto no_memory; } + if (def->console) { + if (virAsprintf(&def->console->info.alias, "console%d", i) < 0) + goto no_memory; + } if (def->watchdog) { if (virAsprintf(&def->watchdog->info.alias, "watchdog%d", 0) < 0) goto no_memory; @@ -3334,7 +3338,10 @@ char * qemuBuildVirtioSerialPortDevStr(virDomainChrDefPtr dev) { virBuffer buf = VIR_BUFFER_INITIALIZER; - virBufferAddLit(&buf, "virtserialport"); + if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE) + virBufferAddLit(&buf, "virtconsole"); + else + virBufferAddLit(&buf, "virtserialport"); if (dev->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { /* Check it's a virtio-serial address */ @@ -4526,6 +4533,41 @@ int qemudBuildCommandLine(virConnectPtr conn, } } + /* Explicit console devices */ + if (def->console) { + virDomainChrDefPtr console = def->console; + char *devstr; + + switch(console->targetType) { + case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO: + if (!(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) { + qemuReportError(VIR_ERR_NO_SUPPORT, "%s", + _("virtio channel requires QEMU to support -device")); + goto error; + } + + ADD_ARG_LIT("-chardev"); + if (!(devstr = qemuBuildChrChardevStr(console))) + goto error; + ADD_ARG(devstr); + + ADD_ARG_LIT("-device"); + if (!(devstr = qemuBuildVirtioSerialPortDevStr(console))) + goto error; + ADD_ARG(devstr); + break; + + case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL: + break; + + default: + qemuReportError(VIR_ERR_NO_SUPPORT, + _("unsupported console target type %s"), + NULLSTR(virDomainChrConsoleTargetTypeToString(console->targetType))); + goto error; + } + } + ADD_ARG_LIT("-usb"); for (i = 0 ; i < def->ninputs ; i++) { virDomainInputDefPtr input = def->inputs[i]; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4558674..4d21035 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2229,6 +2229,8 @@ qemudFindCharDevicePTYsMonitor(virDomainObjPtr vm, LOOKUP_PTYS(vm->def->serials, vm->def->nserials, "serial"); LOOKUP_PTYS(vm->def->parallels, vm->def->nparallels, "parallel"); LOOKUP_PTYS(vm->def->channels, vm->def->nchannels, "channel"); + if (vm->def->console) + LOOKUP_PTYS(&vm->def->console, 1, "console"); #undef LOOKUP_PTYS return 0; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-virtio.args b/tests/qemuxml2argvdata/qemuxml2argv-console-virtio.args new file mode 100644 index 0000000..a55000f --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-console-virtio.args @@ -0,0 +1 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x2 -hda /dev/HostVG/QEMUGuest1 -chardev pty,id=console0 -device virtconsole,chardev=console0 -usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-virtio.xml b/tests/qemuxml2argvdata/qemuxml2argv-console-virtio.xml new file mode 100644 index 0000000..fd72421 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-console-virtio.xml @@ -0,0 +1,27 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory>219200</memory> + <currentMemory>219200</currentMemory> + <vcpu cpuset='1-4,8-20,525'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <disk type='block' device='disk'> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' unit='0'/> + </disk> + <controller type='ide' index='0'/> + <console type='pty'> + <target type='virtio'/> + </console> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 566ab6b..017aad8 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -353,6 +353,8 @@ mymain(int argc, char **argv) QEMUD_CMD_FLAG_NODEFCONFIG); DO_TEST("channel-virtio-auto", QEMUD_CMD_FLAG_DEVICE | QEMUD_CMD_FLAG_NODEFCONFIG); + DO_TEST("console-virtio", QEMUD_CMD_FLAG_DEVICE | + QEMUD_CMD_FLAG_NODEFCONFIG); DO_TEST("watchdog", 0); DO_TEST("watchdog-device", QEMUD_CMD_FLAG_DEVICE | diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio.xml new file mode 100644 index 0000000..431dd34 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio.xml @@ -0,0 +1,29 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory>219200</memory> + <currentMemory>219200</currentMemory> + <vcpu cpuset='1-4,8-20,525'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <disk type='block' device='disk'> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' unit='0'/> + </disk> + <controller type='ide' index='0'/> + <controller type='virtio-serial' index='0'/> + <console type='pty'> + <target type='virtio' port='0'/> + </console> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 08e0e73..dca9b9b 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -182,6 +182,7 @@ mymain(int argc, char **argv) DO_TEST_DIFFERENT("channel-virtio-auto"); DO_TEST_DIFFERENT("console-compat-auto"); DO_TEST_DIFFERENT("disk-scsi-device-auto"); + DO_TEST_DIFFERENT("console-virtio"); virCapabilitiesFree(driver.caps); -- 1.7.1.1

On Mon, Jul 26, 2010 at 03:16:25PM -0400, Cole Robinson wrote:
Enable specifying a virtio console device with:
<console type='pty'> <target type='virtio'/> </console>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
ACK, but one extra thing you need here I think. When I tested it I had to manually add a <controller> element. We should be auto-adding a <controller> for virtio serial if we get a virtio <console> device, in same way we do for virtio <channel> devices. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On 07/28/2010 06:22 AM, Daniel P. Berrange wrote:
On Mon, Jul 26, 2010 at 03:16:25PM -0400, Cole Robinson wrote:
Enable specifying a virtio console device with:
<console type='pty'> <target type='virtio'/> </console>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
ACK, but one extra thing you need here I think. When I tested it I had to manually add a <controller> element. We should be auto-adding a <controller> for virtio serial if we get a virtio <console> device, in same way we do for virtio <channel> devices.
Hmm, I can't reproduce: there is even an explicit unit test case for this, so not sure what steps you took to trigger the issue. I've pushed this series now, let me know if you can still reproduce. Thanks, Cole
participants (2)
-
Cole Robinson
-
Daniel P. Berrange