Re: [libvirt] [PATCH v2] qemu: implement address for isa-serial

2015-06-18 Thread John Ferlan


On 06/16/2015 09:07 AM, James Cowgill wrote:
 I needed to specify the iobase address for certain exotic mips configurations.
 
 Signed-off-by: James Cowgill james...@cowgill.org.uk
 ---
  src/qemu/qemu_command.c| 12 ++--
  .../qemuxml2argv-serial-dev-chardev-iobase.args|  7 +
  .../qemuxml2argv-serial-dev-chardev-iobase.xml | 36 
 ++
  tests/qemuxml2argvtest.c   |  2 ++
  4 files changed, 55 insertions(+), 2 deletions(-)
  create mode 100644 
 tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev-iobase.args
  create mode 100644 
 tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev-iobase.xml
 
 v2:
  - add the serial-dev-chardev-iobase testcase
 

Thanks for the test..

ACK and pushed

John

 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
 index 3886b4f..f63d2a1 100644
 --- a/src/qemu/qemu_command.c
 +++ b/src/qemu/qemu_command.c
 @@ -2693,6 +2693,10 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
info-addr.ccw.cssid,
info-addr.ccw.ssid,
info-addr.ccw.devno);
 +} else if (info-type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA) {
 +virBufferAsprintf(buf, ,iobase=0x%x,irq=0x%x,
 +  info-addr.isa.iobase,
 +  info-addr.isa.irq);
  }
  
  ret = 0;
 @@ -10982,11 +10986,15 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
  break;
  
  case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
 -if (serial-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
 +if (serial-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE 
 +serial-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA) {
  virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
 -   _(no addresses are supported for 
 isa-serial));
 +   _(isa-serial requires address of isa type));
  goto error;
  }
 +
 +if (qemuBuildDeviceAddressStr(cmd, def, serial-info, 
 qemuCaps)  0)
 +goto error;
  break;
  
  case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI:
 diff --git 
 a/tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev-iobase.args 
 b/tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev-iobase.args
 new file mode 100644
 index 000..9d5de02
 --- /dev/null
 +++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev-iobase.args
 @@ -0,0 +1,7 @@
 +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test 
 QEMU_AUDIO_DRV=none \
 +/usr/bin/qemu -S -M \
 +pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -chardev socket,\
 +id=charmonitor,path=/tmp/test-monitor,server,nowait -mon 
 chardev=charmonitor,\
 +id=monitor,mode=readline -no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 
 -chardev \
 +tty,id=charserial0,path=/dev/ttyS2 -device isa-serial,chardev=charserial0,\
 +id=serial0,iobase=0x3f8,irq=0x4 -device 
 virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
 diff --git 
 a/tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev-iobase.xml 
 b/tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev-iobase.xml
 new file mode 100644
 index 000..eb84574
 --- /dev/null
 +++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev-iobase.xml
 @@ -0,0 +1,36 @@
 +domain type='qemu'
 +  nameQEMUGuest1/name
 +  uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid
 +  memory unit='KiB'219100/memory
 +  currentMemory unit='KiB'219100/currentMemory
 +  vcpu placement='static'1/vcpu
 +  os
 +type arch='i686' machine='pc'hvm/type
 +boot dev='hd'/
 +  /os
 +  clock offset='utc'/
 +  on_poweroffdestroy/on_poweroff
 +  on_rebootrestart/on_reboot
 +  on_crashdestroy/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' target='0' unit='0'/
 +/disk
 +controller type='usb' index='0'/
 +controller type='ide' index='0'/
 +serial type='dev'
 +  source path='/dev/ttyS2'/
 +  target port='0'/
 +  address type='isa' iobase='0x3f8' irq='0x4'/
 +/serial
 +console type='dev'
 +  source path='/dev/ttyS2'/
 +  target port='0'/
 +  address type='isa' iobase='0x3f8' irq='0x4'/
 +/console
 +memballoon model='virtio'/
 +  /devices
 +/domain
 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
 index a90f9a6..56b18eb 100644
 --- a/tests/qemuxml2argvtest.c
 +++ b/tests/qemuxml2argvtest.c
 @@ -1045,6 +1045,8 @@ mymain(void)
  QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
  DO_TEST(serial-dev-chardev,
  QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
 +DO_TEST(serial-dev-chardev-iobase,
 +QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, 

[libvirt] [PATCH v2] qemu: implement address for isa-serial

2015-06-16 Thread James Cowgill
I needed to specify the iobase address for certain exotic mips configurations.

Signed-off-by: James Cowgill james...@cowgill.org.uk
---
 src/qemu/qemu_command.c| 12 ++--
 .../qemuxml2argv-serial-dev-chardev-iobase.args|  7 +
 .../qemuxml2argv-serial-dev-chardev-iobase.xml | 36 ++
 tests/qemuxml2argvtest.c   |  2 ++
 4 files changed, 55 insertions(+), 2 deletions(-)
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev-iobase.args
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev-iobase.xml

v2:
 - add the serial-dev-chardev-iobase testcase

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 3886b4f..f63d2a1 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2693,6 +2693,10 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
   info-addr.ccw.cssid,
   info-addr.ccw.ssid,
   info-addr.ccw.devno);
+} else if (info-type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA) {
+virBufferAsprintf(buf, ,iobase=0x%x,irq=0x%x,
+  info-addr.isa.iobase,
+  info-addr.isa.irq);
 }
 
 ret = 0;
@@ -10982,11 +10986,15 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
 break;
 
 case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
-if (serial-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
+if (serial-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE 
+serial-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
-   _(no addresses are supported for isa-serial));
+   _(isa-serial requires address of isa type));
 goto error;
 }
+
+if (qemuBuildDeviceAddressStr(cmd, def, serial-info, qemuCaps) 
 0)
+goto error;
 break;
 
 case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI:
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev-iobase.args 
b/tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev-iobase.args
new file mode 100644
index 000..9d5de02
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev-iobase.args
@@ -0,0 +1,7 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu -S -M \
+pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -chardev socket,\
+id=charmonitor,path=/tmp/test-monitor,server,nowait -mon chardev=charmonitor,\
+id=monitor,mode=readline -no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 
-chardev \
+tty,id=charserial0,path=/dev/ttyS2 -device isa-serial,chardev=charserial0,\
+id=serial0,iobase=0x3f8,irq=0x4 -device 
virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev-iobase.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev-iobase.xml
new file mode 100644
index 000..eb84574
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev-iobase.xml
@@ -0,0 +1,36 @@
+domain type='qemu'
+  nameQEMUGuest1/name
+  uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid
+  memory unit='KiB'219100/memory
+  currentMemory unit='KiB'219100/currentMemory
+  vcpu placement='static'1/vcpu
+  os
+type arch='i686' machine='pc'hvm/type
+boot dev='hd'/
+  /os
+  clock offset='utc'/
+  on_poweroffdestroy/on_poweroff
+  on_rebootrestart/on_reboot
+  on_crashdestroy/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' target='0' unit='0'/
+/disk
+controller type='usb' index='0'/
+controller type='ide' index='0'/
+serial type='dev'
+  source path='/dev/ttyS2'/
+  target port='0'/
+  address type='isa' iobase='0x3f8' irq='0x4'/
+/serial
+console type='dev'
+  source path='/dev/ttyS2'/
+  target port='0'/
+  address type='isa' iobase='0x3f8' irq='0x4'/
+/console
+memballoon model='virtio'/
+  /devices
+/domain
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index a90f9a6..56b18eb 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1045,6 +1045,8 @@ mymain(void)
 QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
 DO_TEST(serial-dev-chardev,
 QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
+DO_TEST(serial-dev-chardev-iobase,
+QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
 DO_TEST(serial-file-chardev,
 QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
 DO_TEST(serial-unix-chardev,
-- 
2.1.4

signature.asc
Description: This is a digitally signed message