if (monitor_chr) {
virBuffer buf = VIR_BUFFER_INITIALIZER;
- if (monitor_json)
- virBufferAddLit(&buf, "control,");
+ /* Use -chardev if it's available */
+ if (qemuCmdFlags & QEMUD_CMD_FLAG_CHARDEV) {
+ qemudBuildCommandLineChrDevChardevStr(monitor_chr, "monitor", &buf);
+ if (virBufferError(&buf)) {
+ virBufferFreeAndReset(&buf);
+ goto no_memory;
+ }
+
+ ADD_ARG_LIT("-chardev");
+ ADD_ARG(virBufferContentAndReset(&buf));
+
+ if (monitor_json)
+ virBufferAddLit(&buf, "control,");
+
+ virBufferAddLit(&buf, "chardev:monitor");
+ }
+
+ else {
+ if (monitor_json)
+ virBufferAddLit(&buf, "control,");
+
+ qemudBuildCommandLineChrDevStr(monitor_chr, &buf);
+ }
- qemudBuildCommandLineChrDevStr(monitor_chr, &buf);
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
goto no_memory;
}
ADD_ARG_LIT("-monitor");
- ADD_ARG(virBufferContentAndReset(&buf));
+ ADD_ARG_LIT(virBufferContentAndReset(&buf));
}
if (def->localtime)
virBuffer buf = VIR_BUFFER_INITIALIZER;
virDomainChrDefPtr serial = def->serials[i];
- qemudBuildCommandLineChrDevStr(serial, &buf);
- if (virBufferError(&buf)) {
- virBufferFreeAndReset(&buf);
- goto no_memory;
+ /* Use -chardev if it's available */
+ if (qemuCmdFlags & QEMUD_CMD_FLAG_CHARDEV) {
+ char id[16];
+
+ if (snprintf(id, sizeof(id), "serial%i", i) > sizeof(id))
+ goto error;
+
+ qemudBuildCommandLineChrDevChardevStr(serial, id, &buf);
+ if (virBufferError(&buf)) {
+ virBufferFreeAndReset(&buf);
+ goto no_memory;
+ }
+
+ ADD_ARG_LIT("-chardev");
+ ADD_ARG(virBufferContentAndReset(&buf));
+
+ virBufferVSprintf(&buf, "chardev:%s", id);
+ if (virBufferError(&buf)) {
+ virBufferFreeAndReset(&buf);
+ goto no_memory;
+ }
+
+ ADD_ARG_LIT("-serial");
+ ADD_ARG(virBufferContentAndReset(&buf));
}
- ADD_ARG_LIT("-serial");
- ADD_ARG(virBufferContentAndReset(&buf));
+ else {
+ qemudBuildCommandLineChrDevStr(serial, &buf);
+ if (virBufferError(&buf)) {
+ virBufferFreeAndReset(&buf);
+ goto no_memory;
+ }
+
+ ADD_ARG_LIT("-serial");
+ ADD_ARG(virBufferContentAndReset(&buf));
+ }
}
}
virBuffer buf = VIR_BUFFER_INITIALIZER;
virDomainChrDefPtr parallel = def->parallels[i];
- qemudBuildCommandLineChrDevStr(parallel, &buf);
- if (virBufferError(&buf)) {
- virBufferFreeAndReset(&buf);
- goto no_memory;
+ /* Use -chardev if it's available */
+ if (qemuCmdFlags & QEMUD_CMD_FLAG_CHARDEV) {
+ char id[16];
+
+ if (snprintf(id, sizeof(id), "parallel%i", i) > sizeof(id))
+ goto error;
+
+ qemudBuildCommandLineChrDevChardevStr(parallel, id, &buf);
+ if (virBufferError(&buf)) {
+ virBufferFreeAndReset(&buf);
+ goto no_memory;
+ }
+
+ ADD_ARG_LIT("-chardev");
+ ADD_ARG(virBufferContentAndReset(&buf));
+
+ virBufferVSprintf(&buf, "chardev:%s", id);
+ if (virBufferError(&buf)) {
+ virBufferFreeAndReset(&buf);
+ goto no_memory;
+ }
+
+ ADD_ARG_LIT("-parallel");
+ ADD_ARG(virBufferContentAndReset(&buf));
}
- ADD_ARG_LIT("-parallel");
- ADD_ARG(virBufferContentAndReset(&buf));
+ else {
+ qemudBuildCommandLineChrDevStr(parallel, &buf);
+ if (virBufferError(&buf)) {
+ virBufferFreeAndReset(&buf);
+ goto no_memory;
+ }
+
+ ADD_ARG_LIT("-parallel");
+ ADD_ARG(virBufferContentAndReset(&buf));
+ }
}
}
-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=monitor,path=/tmp/test-monitor,server,nowait -monitor chardev:monitor -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
--- /dev/null
+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=monitor,path=/tmp/test-monitor,server,nowait -monitor chardev:monitor -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -chardev pty,id=serial0 -serial chardev:serial0 -parallel none -usb
--- /dev/null
+<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>
--- /dev/null
+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=monitor,path=/tmp/test-monitor,server,nowait -monitor chardev:monitor -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
--- /dev/null
+<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>
--- /dev/null
+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=monitor,path=/tmp/test-monitor,server,nowait -monitor chardev:monitor -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -chardev tty,id=serial0,path=/dev/ttyS2 -serial chardev:serial0 -parallel none -usb
--- /dev/null
+<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>
--- /dev/null
+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=monitor,path=/tmp/test-monitor,server,nowait -monitor chardev:monitor -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -chardev file,id=serial0,path=/tmp/serial.log -serial chardev:serial0 -parallel none -usb
--- /dev/null
+<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>
--- /dev/null
+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=monitor,path=/tmp/test-monitor,server,nowait -monitor chardev:monitor -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
--- /dev/null
+<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>
--- /dev/null
+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=monitor,path=/tmp/test-monitor,server,nowait -monitor chardev:monitor -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -chardev pty,id=serial0 -serial chardev:serial0 -parallel none -usb
--- /dev/null
+<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>
--- /dev/null
+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=monitor,path=/tmp/test-monitor,server,nowait -monitor chardev:monitor -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
--- /dev/null
+<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>
--- /dev/null
+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=monitor,path=/tmp/test-monitor,server,nowait -monitor chardev:monitor -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
--- /dev/null
+<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>
--- /dev/null
+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=monitor,path=/tmp/test-monitor,server,nowait -monitor chardev:monitor -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
--- /dev/null
+<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>
--- /dev/null
+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=monitor,path=/tmp/test-monitor,server,nowait -monitor chardev:monitor -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -chardev socket,id=serial0,path=/tmp/serial.sock -serial chardev:serial0 -parallel none -usb
--- /dev/null
+<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>
--- /dev/null
+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=monitor,path=/tmp/test-monitor,server,nowait -monitor chardev:monitor -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -chardev vc,id=serial0 -serial chardev:serial0 -parallel none -usb
--- /dev/null
+<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>
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);