[libvirt] [PATCH 1/3] Make QEMU driver use -chardev everywhere when it's available

Matthew Booth mbooth at redhat.com
Mon Nov 23 12:30:27 UTC 2009


Change -monitor, -serial and -parallel output to use -chardev if it is
available.

* src/qemu/qemu_conf.c: Update qemudBuildCommandLine to use -chardev where
  available.
* tests/qemuxml2argvtest.c tests/qemuxml2argvdata/: Add -chardev equivalents for
  all current serial and parallel tests.
---
 src/qemu/qemu_conf.c                               |   93 ++++++++++++++++---
 .../qemuxml2argv-channel-guestfwd.args             |    2 +-
 .../qemuxml2argv-console-compat-chardev.args       |    1 +
 .../qemuxml2argv-console-compat-chardev.xml        |   28 ++++++
 .../qemuxml2argv-parallel-tcp-chardev.args         |    1 +
 .../qemuxml2argv-parallel-tcp-chardev.xml          |   27 ++++++
 .../qemuxml2argv-serial-dev-chardev.args           |    1 +
 .../qemuxml2argv-serial-dev-chardev.xml            |   30 ++++++
 .../qemuxml2argv-serial-file-chardev.args          |    1 +
 .../qemuxml2argv-serial-file-chardev.xml           |   30 ++++++
 .../qemuxml2argv-serial-many-chardev.args          |    1 +
 .../qemuxml2argv-serial-many-chardev.xml           |   32 +++++++
 .../qemuxml2argv-serial-pty-chardev.args           |    1 +
 .../qemuxml2argv-serial-pty-chardev.xml            |   28 ++++++
 .../qemuxml2argv-serial-tcp-chardev.args           |    1 +
 .../qemuxml2argv-serial-tcp-chardev.xml            |   32 +++++++
 .../qemuxml2argv-serial-tcp-telnet-chardev.args    |    1 +
 .../qemuxml2argv-serial-tcp-telnet-chardev.xml     |   32 +++++++
 .../qemuxml2argv-serial-udp-chardev.args           |    1 +
 .../qemuxml2argv-serial-udp-chardev.xml            |   32 +++++++
 .../qemuxml2argv-serial-unix-chardev.args          |    1 +
 .../qemuxml2argv-serial-unix-chardev.xml           |   30 ++++++
 .../qemuxml2argv-serial-vc-chardev.args            |    1 +
 .../qemuxml2argv-serial-vc-chardev.xml             |   28 ++++++
 tests/qemuxml2argvtest.c                           |   12 +++
 25 files changed, 431 insertions(+), 16 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-compat-chardev.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-compat-chardev.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-parallel-tcp-chardev.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-parallel-tcp-chardev.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-file-chardev.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-file-chardev.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-many-chardev.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-many-chardev.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-pty-chardev.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-pty-chardev.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-chardev.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-chardev.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-telnet-chardev.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-telnet-chardev.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-udp-chardev.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-udp-chardev.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-unix-chardev.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-unix-chardev.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-vc-chardev.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-vc-chardev.xml

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index f26e94d..51d8515 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1858,12 +1858,27 @@ int qemudBuildCommandLine(virConnectPtr conn,
     if (monitor_chr) {
         virBuffer buf = VIR_BUFFER_INITIALIZER;
 
-        qemudBuildCommandLineChrDevStr(monitor_chr, &buf);
-        if (virBufferError(&buf))
-            goto error;
+        /* Use -chardev if it's available */
+        if (qemuCmdFlags & QEMUD_CMD_FLAG_CHARDEV) {
+            qemudBuildCommandLineChrDevChardevStr(monitor_chr, "monitor", &buf);
+            if (virBufferError(&buf))
+                goto error;
+
+            ADD_ARG_LIT("-chardev");
+            ADD_ARG(virBufferContentAndReset(&buf));
+
+            ADD_ARG_LIT("-monitor");
+            ADD_ARG_LIT("chardev:monitor");
+        }
+
+        else {
+            qemudBuildCommandLineChrDevStr(monitor_chr, &buf);
+            if (virBufferError(&buf))
+                goto error;
 
-        ADD_ARG_LIT("-monitor");
-        ADD_ARG(virBufferContentAndReset(&buf));
+            ADD_ARG_LIT("-monitor");
+            ADD_ARG(virBufferContentAndReset(&buf));
+        }
     }
 
     if (def->localtime)
@@ -2146,12 +2161,36 @@ int qemudBuildCommandLine(virConnectPtr conn,
             virBuffer buf = VIR_BUFFER_INITIALIZER;
             virDomainChrDefPtr serial = def->serials[i];
 
-            qemudBuildCommandLineChrDevStr(serial, &buf);
-            if (virBufferError(&buf))
-                goto error;
+            /* Use -chardev if it's available */
+            if (qemuCmdFlags & QEMUD_CMD_FLAG_CHARDEV) {
+                char id[16];
 
-            ADD_ARG_LIT("-serial");
-            ADD_ARG(virBufferContentAndReset(&buf));
+                if (snprintf(id, sizeof(id), "serial%i", i) > sizeof(id))
+                    goto error;
+
+                qemudBuildCommandLineChrDevChardevStr(serial, id, &buf);
+                if (virBufferError(&buf))
+                    goto error;
+
+                ADD_ARG_LIT("-chardev");
+                ADD_ARG(virBufferContentAndReset(&buf));
+
+                virBufferVSprintf(&buf, "chardev:%s", id);
+                if (virBufferError(&buf))
+                    goto error;
+
+                ADD_ARG_LIT("-serial");
+                ADD_ARG(virBufferContentAndReset(&buf));
+            }
+
+            else {
+                qemudBuildCommandLineChrDevStr(serial, &buf);
+                if (virBufferError(&buf))
+                    goto error;
+
+                ADD_ARG_LIT("-serial");
+                ADD_ARG(virBufferContentAndReset(&buf));
+            }
         }
     }
 
@@ -2163,12 +2202,36 @@ int qemudBuildCommandLine(virConnectPtr conn,
             virBuffer buf = VIR_BUFFER_INITIALIZER;
             virDomainChrDefPtr parallel = def->parallels[i];
 
-            qemudBuildCommandLineChrDevStr(parallel, &buf);
-            if (virBufferError(&buf))
-                goto error;
+            /* Use -chardev if it's available */
+            if (qemuCmdFlags & QEMUD_CMD_FLAG_CHARDEV) {
+                char id[16];
 
-            ADD_ARG_LIT("-parallel");
-            ADD_ARG(virBufferContentAndReset(&buf));
+                if (snprintf(id, sizeof(id), "parallel%i", i) > sizeof(id))
+                    goto error;
+
+                qemudBuildCommandLineChrDevChardevStr(parallel, id, &buf);
+                if (virBufferError(&buf))
+                    goto error;
+
+                ADD_ARG_LIT("-chardev");
+                ADD_ARG(virBufferContentAndReset(&buf));
+
+                virBufferVSprintf(&buf, "chardev:%s", id);
+                if (virBufferError(&buf))
+                    goto error;
+
+                ADD_ARG_LIT("-parallel");
+                ADD_ARG(virBufferContentAndReset(&buf));
+            }
+
+            else {
+                qemudBuildCommandLineChrDevStr(parallel, &buf);
+                if (virBufferError(&buf))
+                    goto error;
+
+                ADD_ARG_LIT("-parallel");
+                ADD_ARG(virBufferContentAndReset(&buf));
+            }
         }
     }
 
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-guestfwd.args b/tests/qemuxml2argvdata/qemuxml2argv-channel-guestfwd.args
index b5bb46d..f3b0c30 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-channel-guestfwd.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-guestfwd.args
@@ -1 +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 none -parallel none -chardev pipe,id=channel0,path=/tmp/guestfwd -net user,guestfwd=tcp:10.0.2.1:4600-chardev:channel0 -usb
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -chardev socket,id=monitor0,path=/tmp/test-monitor,server,nowait -monitor chardev:monitor0 -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -chardev pipe,id=channel0,path=/tmp/guestfwd -net user,guestfwd=tcp:10.0.2.1:4600-chardev:channel0 -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-compat-chardev.args b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-chardev.args
new file mode 100644
index 0000000..1237250
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-chardev.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 -chardev socket,id=monitor0,path=/tmp/test-monitor,server,nowait -monitor chardev:monitor0 -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -chardev pty,id=serial0 -serial chardev:serial0 -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-compat-chardev.xml b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-chardev.xml
new file mode 100644
index 0000000..c16ae07
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-chardev.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>
+    <serial type='pty'>
+      <target port='0'/>
+    </serial>
+    <console type='pty'>
+      <target port='0'/>
+    </console>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-parallel-tcp-chardev.args b/tests/qemuxml2argvdata/qemuxml2argv-parallel-tcp-chardev.args
new file mode 100644
index 0000000..65783fb
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-parallel-tcp-chardev.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 -chardev socket,id=monitor0,path=/tmp/test-monitor,server,nowait -monitor chardev:monitor0 -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -chardev socket,id=parallel0,host=127.0.0.1,port=9999,server,nowait -parallel chardev:parallel0 -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-parallel-tcp-chardev.xml b/tests/qemuxml2argvdata/qemuxml2argv-parallel-tcp-chardev.xml
new file mode 100644
index 0000000..08176f1
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-parallel-tcp-chardev.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>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>
+    <parallel type='tcp'>
+      <source mode='bind' host='127.0.0.1' service='9999'/>
+      <protocol type='raw'/>
+      <target port='0'/>
+    </parallel>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev.args b/tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev.args
new file mode 100644
index 0000000..7ecb3e8
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev.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 -chardev socket,id=monitor0,path=/tmp/test-monitor,server,nowait -monitor chardev:monitor0 -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -chardev tty,id=serial0,path=/dev/ttyS2 -serial chardev:serial0 -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev.xml
new file mode 100644
index 0000000..2b8ef5a
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev.xml
@@ -0,0 +1,30 @@
+<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>
+    <serial type='dev'>
+      <source path='/dev/ttyS2'/>
+      <target port='0'/>
+    </serial>
+    <console type='dev'>
+      <source path='/dev/ttyS2'/>
+      <target port='0'/>
+    </console>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-file-chardev.args b/tests/qemuxml2argvdata/qemuxml2argv-serial-file-chardev.args
new file mode 100644
index 0000000..fd3cc4e
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-file-chardev.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 -chardev socket,id=monitor0,path=/tmp/test-monitor,server,nowait -monitor chardev:monitor0 -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -chardev file,id=serial0,path=/tmp/serial.log -serial chardev:serial0 -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-file-chardev.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-file-chardev.xml
new file mode 100644
index 0000000..3726816
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-file-chardev.xml
@@ -0,0 +1,30 @@
+<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>
+    <serial type='file'>
+      <source path='/tmp/serial.log'/>
+      <target port='0'/>
+    </serial>
+    <console type='file'>
+      <source path='/tmp/serial.log'/>
+      <target port='0'/>
+    </console>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-many-chardev.args b/tests/qemuxml2argvdata/qemuxml2argv-serial-many-chardev.args
new file mode 100644
index 0000000..46113fc
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-many-chardev.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 -chardev socket,id=monitor0,path=/tmp/test-monitor,server,nowait -monitor chardev:monitor0 -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -chardev pty,id=serial0 -serial chardev:serial0 -chardev file,id=serial1,path=/tmp/serial.log -serial chardev:serial1 -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-many-chardev.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-many-chardev.xml
new file mode 100644
index 0000000..444e85b
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-many-chardev.xml
@@ -0,0 +1,32 @@
+<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>
+    <serial type='pty'>
+      <target port='0'/>
+    </serial>
+    <serial type='file'>
+      <source path='/tmp/serial.log'/>
+      <target port='1'/>
+    </serial>
+    <console type='pty'>
+      <target port='0'/>
+    </console>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-pty-chardev.args b/tests/qemuxml2argvdata/qemuxml2argv-serial-pty-chardev.args
new file mode 100644
index 0000000..1237250
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-pty-chardev.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 -chardev socket,id=monitor0,path=/tmp/test-monitor,server,nowait -monitor chardev:monitor0 -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -chardev pty,id=serial0 -serial chardev:serial0 -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-pty-chardev.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-pty-chardev.xml
new file mode 100644
index 0000000..c16ae07
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-pty-chardev.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>
+    <serial type='pty'>
+      <target port='0'/>
+    </serial>
+    <console type='pty'>
+      <target port='0'/>
+    </console>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-chardev.args b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-chardev.args
new file mode 100644
index 0000000..6255103
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-chardev.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 -chardev socket,id=monitor0,path=/tmp/test-monitor,server,nowait -monitor chardev:monitor0 -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -chardev socket,id=serial0,host=127.0.0.1,port=9999 -serial chardev:serial0 -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-chardev.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-chardev.xml
new file mode 100644
index 0000000..3bcf62d
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-chardev.xml
@@ -0,0 +1,32 @@
+<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>
+    <serial type='tcp'>
+      <source mode='connect' host='127.0.0.1' service='9999'/>
+      <protocol type='raw'/>
+      <target port='0'/>
+    </serial>
+    <console type='tcp'>
+      <source mode='connect' host='127.0.0.1' service='9999'/>
+      <protocol type='raw'/>
+      <target port='0'/>
+    </console>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-telnet-chardev.args b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-telnet-chardev.args
new file mode 100644
index 0000000..c807e64
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-telnet-chardev.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 -chardev socket,id=monitor0,path=/tmp/test-monitor,server,nowait -monitor chardev:monitor0 -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -chardev socket,id=serial0,host=127.0.0.1,port=9999,telnet,server,nowait -serial chardev:serial0 -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-telnet-chardev.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-telnet-chardev.xml
new file mode 100644
index 0000000..bea4306
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-telnet-chardev.xml
@@ -0,0 +1,32 @@
+<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>
+    <serial type='tcp'>
+      <source mode='bind' host='127.0.0.1' service='9999'/>
+      <protocol type='telnet'/>
+      <target port='0'/>
+    </serial>
+    <console type='tcp'>
+      <source mode='bind' host='127.0.0.1' service='9999'/>
+      <protocol type='telnet'/>
+      <target port='0'/>
+    </console>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-udp-chardev.args b/tests/qemuxml2argvdata/qemuxml2argv-serial-udp-chardev.args
new file mode 100644
index 0000000..088c461
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-udp-chardev.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 -chardev socket,id=monitor0,path=/tmp/test-monitor,server,nowait -monitor chardev:monitor0 -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -chardev udp,id=serial0,host=127.0.0.1,port=9998,localaddr=127.0.0.1,localport=9999 -serial chardev:serial0 -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-udp-chardev.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-udp-chardev.xml
new file mode 100644
index 0000000..115166d
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-udp-chardev.xml
@@ -0,0 +1,32 @@
+<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>
+    <serial 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'/>
+    </serial>
+    <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'/>
+    </console>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-unix-chardev.args b/tests/qemuxml2argvdata/qemuxml2argv-serial-unix-chardev.args
new file mode 100644
index 0000000..92a7efc
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-unix-chardev.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 -chardev socket,id=monitor0,path=/tmp/test-monitor,server,nowait -monitor chardev:monitor0 -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -chardev socket,id=serial0,path=/tmp/serial.sock -serial chardev:serial0 -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-unix-chardev.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-unix-chardev.xml
new file mode 100644
index 0000000..4236b4c
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-unix-chardev.xml
@@ -0,0 +1,30 @@
+<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>
+    <serial type='unix'>
+      <source mode='connect' path='/tmp/serial.sock'/>
+      <target port='0'/>
+    </serial>
+    <console type='unix'>
+      <source mode='connect' path='/tmp/serial.sock'/>
+      <target port='0'/>
+    </console>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-vc-chardev.args b/tests/qemuxml2argvdata/qemuxml2argv-serial-vc-chardev.args
new file mode 100644
index 0000000..c427c0e
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-vc-chardev.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 -chardev socket,id=monitor0,path=/tmp/test-monitor,server,nowait -monitor chardev:monitor0 -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -chardev vc,id=serial0 -serial chardev:serial0 -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-vc-chardev.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-vc-chardev.xml
new file mode 100644
index 0000000..1e5de8f
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-vc-chardev.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>
+    <serial type='vc'>
+      <target port='0'/>
+    </serial>
+    <console type='vc'>
+      <target port='0'/>
+    </console>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index c948379..da6b761 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -269,6 +269,18 @@ mymain(int argc, char **argv)
     DO_TEST("parallel-tcp", 0);
     DO_TEST("console-compat", 0);
 
+    DO_TEST("serial-vc-chardev", QEMUD_CMD_FLAG_CHARDEV);
+    DO_TEST("serial-pty-chardev", QEMUD_CMD_FLAG_CHARDEV);
+    DO_TEST("serial-dev-chardev", QEMUD_CMD_FLAG_CHARDEV);
+    DO_TEST("serial-file-chardev", QEMUD_CMD_FLAG_CHARDEV);
+    DO_TEST("serial-unix-chardev", QEMUD_CMD_FLAG_CHARDEV);
+    DO_TEST("serial-tcp-chardev", QEMUD_CMD_FLAG_CHARDEV);
+    DO_TEST("serial-udp-chardev", QEMUD_CMD_FLAG_CHARDEV);
+    DO_TEST("serial-tcp-telnet-chardev", QEMUD_CMD_FLAG_CHARDEV);
+    DO_TEST("serial-many-chardev", QEMUD_CMD_FLAG_CHARDEV);
+    DO_TEST("parallel-tcp-chardev", QEMUD_CMD_FLAG_CHARDEV);
+    DO_TEST("console-compat-chardev", QEMUD_CMD_FLAG_CHARDEV);
+
     DO_TEST("channel-guestfwd", QEMUD_CMD_FLAG_CHARDEV);
 
     DO_TEST("sound", 0);
-- 
1.6.5.2




More information about the libvir-list mailing list