[libvirt] sVirt shouldn't let Nova do stupid things

2016-03-08 Thread Matthew Booth
Nova just released a fix for this critical CVE:
https://bugs.launchpad.net/nova/+bug/1548450

To summarise, it's a qcow2 backing file exploit. The user writes a
malicious qcow2 header to the top of a raw disk, then triggers a bug in
Nova which causes it to do format detection.

If you read the bug and comments, you'll see that when I initially reported
it I was fairly dismissive of its impact because it's only exploitable
through libvirt, and the instance is going to be confined by SELinux. But
then Dan B points out that sVirt is going to trust whatever Nova tells it
to do and label it appropriately. Cue rapid ramping of severity, and it
turns out this allows an unprivileged user to read anything on the host,
including all raw block devices.

I'm not sure exactly where, but something in this stack has failed us.
Let's be clear a couple of things, though:

1. This is an egregious, stupid bug in Nova, and Nova shouldn't have
egregious, stupid bugs.
2. SELinux should prevent obviously bad things from happening, even in the
presence of egregious, stupid bugs.

I point that out to head off: 'Well Nova shouldn't do that'. Of course it
shouldn't. However, it might, and when it does, I'd like to think that
SELinux has its back. It doesn't, though.

As I understand it, sVirt is the mechanism libvirt uses for controlling
SELinux. I wonder if the current sVirt model is enough to cover the use
case where the thing connecting to libvirt is large enough to have its own
serious bugs. Is there any way we could define a sane set of operations
independent of Nova?

Matt
-- 
Matthew Booth
Red Hat Engineering, Virtualisation Team

Phone: +442070094448 (UK)
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [libguestfs] Options for hotplugging

2012-08-21 Thread Matthew Booth

On 20/08/12 22:07, Richard W.M. Jones wrote:

(1) The raw libvirt option

In this one we'd simply provide thin wrappers around
virDomainAttachDevice and virDomainDetactDevice, and leave it up to
the user to know what they're doing.

The problem with this is the hidden appliance disk.  We certainly
don't want the user to accidentally detach that(!)  It's also
undesirable for there to be a hole in the naming scheme so that
you'd have:

   /dev/sda - your normal drives
   /dev/sdb -
  [/dev/sdc # sorry, you can't use this, we won't tell you why]
   /dev/sdd - your first hotplugged device

As far as I know, the kernel assigns /dev/sdX names on a first-free
basis, so there's no way to permanently put the appliance at
/dev/sdzzz (if there is, please let me know!)


There are numerous reasons not to like this. If there were any reason to 
want to expose the underlying libvirt api directly I'd suggest it only 
be a debug option.



(2) The slots option

In this option you'd have to use null devices to reserve the maximum
number of drive slots that you're going to use in the libguestfs
handle before launch.  Then after launching you'd be allowed to
hotplug only those slots.

So for example:

   guestfs_add_drive (g, /dev/null); # reserves /dev/sda
   guestfs_add_drive (g, /dev/null); # reserves /dev/sdb
   guestfs_add_drive (g, /dev/null); # reserves /dev/sdc
   guestfs_launch (g);
   guestfs_hotplug (g, 1, /tmp/foo); # replaces index 1 == /dev/sdb
   guestfs_hotplug (g, 3, /tmp/foo); # error!

Although ugly, in some ways this is quite attractive.  It maps easily
into guestfish scripts.  You have contiguous device naming.  You often
know how many drives you'll need in advance, and if you don't then you
can reserve up to max_disks-1.


Echo Dan's general dislike of this.


(3) The serial numbers option

This was Dan's suggestion.  Hotplugged drives are known only by their
serial number.  ie. We hotplug them via libvirt using the serial/
field, and then they are accessed using /dev/disk/by-id/serial.

This is tempting, but unfortunately it doesn't quite work in stock
udev, because the actual name used is:

   /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_SERIAL

We could add a custom udev rule to get the path we wanted.


Presumably you would specify then serial number when adding the drive? 
I'm not opposed to this, but it's not the simplest.



(4) The rewriting device names option

Since we already have the infrastructure to rewrite device names, we
could do some complicated and hairy device name rewriting to make
names appear continguous, even though there's an hidden appliance
drive.

This is my least favourite option, mainly because of the complexity,
and complexity is bound to lead to bugs.


I don't think this rewriting is required. Having a hole in the drive 
letters isn't a big deal. In fact, I suspect it would be simpler in most 
code to use returned rather than calculated device names.


I'd suggest a very simple api:

char * guestfs_hotplug_drive(g, path, opts)

This does the same as add_drive, except that it works after launch and 
returns the api name of the newly added drive. list_devices will return 
a list with a hole in it. If it isn't already there, we can add some 
generic code to methods taking a Device parameter to guard against 
passing in the root device.


Matt
--
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] xenapi: Improve error message on session failure

2011-06-07 Thread Matthew Booth
XenAPI session login can fail for a number of reasons, but currently no specific
reason is displayed to the user, e.g.:

virsh -c XenAPI://citrix-xen.example.com/
Enter username for citrix-xen.example.com: root
Enter root's password for citrix-xen.example.com:
error: authentication failed: (null)
error: failed to connect to the hypervisor

This patch displays the session error description on failure.
---
 src/xenapi/xenapi_driver.c |   20 ++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index 6f64208..3fc35c6 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -166,7 +166,22 @@ xenapiOpen (virConnectPtr conn, virConnectAuthPtr auth, 
int flags ATTRIBUTE_UNUS
 privP-session = xen_session_login_with_password(call_func, privP, 
username,
  password, 
xen_api_latest_version);
 
-if (privP-session != NULL  privP-session-ok) {
+if (privP-session == NULL) {
+/* From inspection of xen_session_login_with_password in
+ * libxenserver(Version 5.6.100-1), this appears not to be currently
+ * possible. The only way for this to be NULL would be on malloc
+ * failure, except that the code doesn't check for this and would
+ * segfault before returning.
+ *
+ * We don't assume the reason here for a failure in an external 
library.
+ */
+xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
+  _(Failed to allocate xen session));
+
+goto error;
+}
+
+if (privP-session-ok) {
 conn-privateData = privP;
 
 VIR_FREE(username);
@@ -175,7 +190,8 @@ xenapiOpen (virConnectPtr conn, virConnectAuthPtr auth, int 
flags ATTRIBUTE_UNUS
 return VIR_DRV_OPEN_SUCCESS;
 }
 
-xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED, NULL);
+xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED,
+  *privP-session-error_description);
 
   error:
 VIR_FREE(username);
-- 
1.7.4.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] storage: fix volDelete return when volume still being allocated

2011-05-25 Thread Matthew Booth
volDelete used to return VIR_ERR_INTERNAL_ERROR when attempting to delete a
volume which was still being allocated. It should return
VIR_ERR_OPERATION_INVALID.

* src/storage/storage_driver.c: Fix return of volDelete.
---
 src/storage/storage_driver.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 2da2feb..d9c2137 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -1914,7 +1914,7 @@ storageVolumeDelete(virStorageVolPtr obj,
 }
 
 if (vol-building) {
-virStorageReportError(VIR_ERR_INTERNAL_ERROR,
+virStorageReportError(VIR_ERR_OPERATION_INVALID,
   _(volume '%s' is still being allocated.),
   vol-name);
 goto cleanup;
-- 
1.7.4.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] Changing the default for qcow2 creation

2010-10-25 Thread Matthew Booth
I've recently been investigating a severe performance issue I noticed 
when writing to a qcow2-backed image. When virt-v2v is doing a format 
conversion from raw to qcow2, it does the following:


1. Create a new qcow2 image
2. Launch a libguestfs appliance (kvm) using the new image
3. Write the source raw data to the appliance's block device

I noticed that the same process writing to a raw image rather than a 
qcow2 image was adequately fast, and decided to do some testing. I've 
attached my simple test program.[1] It does the following:


1. Start an appliance with test.img as a disk.
2. Format test.img with ext2.
3. Create a file /test
4. Write 256M of data to /test in 2M chunks

Only step 4 is timed. I ran the program against test.img prepared in 4 
different ways:


1. A sparse raw file:15.3 seconds
truncate --size 300M test.img
2. A preallocated raw file:  14.8 seconds
fallocate -l 300M test.img
3. A sparse qcow2 file: 223.0 seconds
qemu-img create -f qcow2 test.img 300M
4. A metadata preallocated qcow2 file:   14.5 seconds
qemu-img create -f qcow2 -o preallocated=metadata test.img 300M

With the exception of (3), I ran the test 3 times and took the middle 
time rounded to 1DP. I saw about 5-10% variation. I only ran the test 
against (3) once.


The precise ordering of 1, 2 and 4 is surprising, but given the 
variation probably not that interesting: they're all about the same. The 
interesting thing is that the overhead of qcow2 metadata creation during 
the test seems to account for a 15x performance penalty.


I had a cursory look at metadata preallocation, which I hadn't been 
aware of before today. Creating a qcow2 image of any size with no 
preallocation results in a 136k file. If you preallocate the metadata, a 
sparse file is created large enough to accomodate the entire image, with 
136k actually used. In the above 300M case this is 204k. On a slightly 
more practical 20G image, 3.3M is preallocated. It's also worth noting 
that the image takes considerably longer to create. On my laptop, 
creation without preallocation is 'instantaneous' at any size. With 
preallocation, a 20G image takes 6 seconds to create, and a 100G image 
takes 26 seconds.


libvirt's qemu driver doesn't currently preallocate qcow2 metadata when 
creating a new image. Given the tiny disk space overhead of the metadata 
(0.02%) and the small processing overhead of pre-creation relative to 
subsequent creation on-the-fly, I suggest that the libvirt qemu driver 
is updated to pre-allocate metadata by default.


Thoughts?

Matt

[1] Note that I'm running this against libguestfs from git, which uses 
virtio-serial rather than usermode networking for appliance-host 
communication. This change alone improved the performance of this test 
by about 10x. If your numbers don't match mine, that's probably why. I 
don't know off the top of my head if this change has made it into F14 
yet. It's definitely not in F13.

--
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490


write-test.pl
Description: Perl program
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH] Remove unused nwfilter field from struct remote_error

2010-05-06 Thread Matthew Booth
Change 965466c1 added a new field to struct remote_error, which broke the RPC
protocol. Fortunately the new field is unused, so this change simply removes it
again.

* src/remote/remote_protocol.(c|h|x): Remove remote_nwfilter from struct
  remote_error
---
 src/remote/remote_protocol.c |2 --
 src/remote/remote_protocol.h |1 -
 src/remote/remote_protocol.x |1 -
 3 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/src/remote/remote_protocol.c b/src/remote/remote_protocol.c
index 187281d..972bf52 100644
--- a/src/remote/remote_protocol.c
+++ b/src/remote/remote_protocol.c
@@ -227,8 +227,6 @@ xdr_remote_error (XDR *xdrs, remote_error *objp)
  return FALSE;
  if (!xdr_remote_network (xdrs, objp-net))
  return FALSE;
- if (!xdr_remote_nwfilter (xdrs, objp-nwfilter))
- return FALSE;
 return TRUE;
 }
 
diff --git a/src/remote/remote_protocol.h b/src/remote/remote_protocol.h
index 6f01da7..a600af6 100644
--- a/src/remote/remote_protocol.h
+++ b/src/remote/remote_protocol.h
@@ -143,7 +143,6 @@ struct remote_error {
 int int1;
 int int2;
 remote_network net;
-remote_nwfilter nwfilter;
 };
 typedef struct remote_error remote_error;
 
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 8000ee0..1ce488c 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -266,7 +266,6 @@ struct remote_error {
 int int1;
 int int2;
 remote_network net;
-remote_nwfilter nwfilter;
 };
 
 /* Authentication types available thus far */
-- 
1.6.6.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] Fwd: Re: need your help about virito vmchannel

2010-05-04 Thread Matthew Booth
FYI for the list. I haven't looked at this yet.

Matt

 Original Message 
Subject: Re: need your help about virito vmchannel
Date: Tue, 4 May 2010 18:00:02 +0530
From: Amit Shah amit.s...@redhat.com
To: Matthew Booth mbo...@redhat.com
CC: Jianlin Liu jia...@redhat.com

On (Tue) May 04 2010 [13:18:30], Matthew Booth wrote:
 On 04/05/10 12:48, Jianlin Liu wrote:
  Hi Matthew,
  
 I want to create a virtio vm channel in my guest. So I add the 
  followiong to my guest xml file:
  channel type='pty'
target type='virtio' name='org.linux-kvm.port.0'/
  /channel
 
 Jianlin,
 
 While I wrote the libvirt-vmchannel glue, I'm not actually that
 familiar with vmchannel itself. I've cc'd Amit, who hopefully might
 recognise this problem and tell me how to fix it ;)
 
 Amit,
 
 Any idea what's going on here?

Yes:

  Then I try to start the guest:
  # virsh start winxp
  error: Failed to start domain winxp
  error: internal error Process exited while reading console log output: char 
  device redirected to /dev/pts/4
  char device redirected to /dev/pts/5
  qemu-kvm: -device 
  virtio-serial-pci,id=virtio-serial0,max_ports=0,vectors=0,bus=pci.0,addr=0x5:
   Device 'virtio-serial-pci' could not be initialized

With max_ports=0, the virtio-serial device doesn't get created and hence
this error.

Amit

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] Don't build nwfilter examples when not building libvirtd

2010-04-16 Thread Matthew Booth
 * Makefile.am: Make examples/xml/nwfilter conditional on WITH_LIBVIRTD
---
 Makefile.am |7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index dd334b5..40352c4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,8 +5,11 @@ GENHTML = genhtml
 
 SUBDIRS = gnulib/lib include src daemon tools proxy docs gnulib/tests \
   python tests po examples/domain-events/events-c examples/hellolibvirt \
-  examples/dominfo examples/domsuspend examples/python examples/apparmor \
-  examples/xml/nwfilter
+  examples/dominfo examples/domsuspend examples/python examples/apparmor
+
+if WITH_LIBVIRTD
+  SUBDIRS += examples/xml/nwfilter
+endif
 
 ACLOCAL_AMFLAGS = -I m4 -I gnulib/m4
 
-- 
1.6.6.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] Problems accessing ESX using libvirt

2010-04-08 Thread Matthew Booth
On 08/04/10 16:37, Matthias Bolte wrote:
 ESX support was added in libvirt 0.7.0. So libvirt 0.6.3 is too old.
 
 Libvirt will give unexpected error messages when you give it URIs that
 no driver handles. For example if no local driver claims to handle an
 URI the remote driver will try to connect to a libvirtd on the server
 and uses TLS (default libvirt port 16514) for that. That's what you
 see in the tcpdump there.

Thanks, Matthias.

Matt
-- 
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

M:   +44 (0)7977 267231
GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] virtio serial config

2010-03-18 Thread Matthew Booth
On 18/03/10 14:31, Matthew Whitehead wrote:
 Matthew,
   Dan B referred me to you. I want to create 4 (or more) virtual serial 
 devices between two KVM virtual hosts. The output of one serial device would 
 be the input to the other. Virt-manager doesn't provide this, so I'm prepared 
 to hack the config files manually. Unfortunately, I can't find documentation 
 on the syntax.
 
 Can you assist?

I'm normally the one complaining about lack of documentation :) That's
quite an oversight.

The basic syntax for a virtio-serial channel is:

channel type='pty'
  target type='virtio' name='org.linux-kvm.port.1'/
/channel

You'll want 4 channel/ entries per guest. Give them all different names.

The interesting bit is going to be plugging the character devices
together on the host. I'm pretty sure you'll have to use pipes. Note
that afaik the libvirt documentation on this is wrong and misleading.
Don't read it, just test instead :)

IIRC, the way pipes actually work is that it expects to be able to use 2
pipes based on the path you specify, called foo.in and foo.out. I seem
to recall you need to create these manually too. The following advice is
completely untested. It may also be responsible for global warming and
the rise of reality TV.

Host:

# mkfifo /tmp/guesta-virtioserial{1,2}.{in,out}
# ln /tmp/guesta-virtioserial1.in /tmp/guestb-virtioserial1.out
# ln /tmp/guesta-virtioserial1.out /tmp/guestb-virtioserial1.in
# ln /tmp/guesta-virtioserial2.in /tmp/guestb-virtioserial2.out
# ln /tmp/guesta-virtioserial2.out /tmp/guestb-virtioserial2.in

Guest A:

channel type='pipe'
  source path=/tmp/guesta-virtioserial1/
  target type='virtio' name='org.linux-kvm.port.1'/
/channel
channel type='pipe'
  source path=/tmp/guesta-virtioserial2/
  target type='virtio' name='org.linux-kvm.port.2'/
/channel

Guest B:

channel type='pipe'
  source path=/tmp/guestb-virtioserial1/
  target type='virtio' name='org.linux-kvm.port.1'/
/channel
channel type='pipe'
  source path=/tmp/guestb-virtioserial2/
  target type='virtio' name='org.linux-kvm.port.2'/
/channel

At this point, both virtio-serial devices in each guest should be
full-duplex.

Matt
-- 
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

M:   +44 (0)7977 267231
GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] libvirt XML format.

2010-02-18 Thread Matthew Booth
On 18/02/10 05:28, Kumar L Srikanth-B22348 wrote:
 Now, I created a bridge br0 in the host machine with the IP 172.16.1.10.
 I want to assign an IP address[172.16.1.15] to the domain, so that the
 host machine and domain will ping each other. I tried to assign
 'default' network to the domain by adding the following XML block to the
 above XML file:
 interface type='network'
   source network='default'/
 /interface
 But, when I start the domain I got the following error in the virsh
 console:
 
 error: Failed to start domain vm1_fedora
 error: Failed to add veth0 device to virbr0: No such device

I'm not at all familiar with LXC domains, however I think I can see the
problem. The above network definition is for a managed network called
'default'. You can see its configuration using virsh. Here's mine:

# virsh net-dumpxml default
network
  namedefault/name
  uuid593e1d02-48b6-4ca2-ab49-8b1bca4ddb50/uuid
  forward mode='nat'/
  bridge name='virbr0' stp='on' delay='0' /
  ip address='192.168.122.1' netmask='255.255.255.0'
dhcp
  range start='192.168.122.2' end='192.168.122.254' /
/dhcp
  /ip
/network

Note that the bridge is called 'virbr0'. You don't seem to have virbr0
on your system, so my guess is the default network has been stopped or
unconfigured somehow. However, it doesn't sound like you want to use a
managed network, you want to use your existing bridge. You need to
replace your XML above with the following:

 interface type='bridge'
  source bridge='br0'/
 /interface

For more info have a look here:

http://libvirt.org/formatdomain.html#elementsNIC

Note the sections 'Virtual network' and 'Bridge to LAN'.

Matt
-- 
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

M:   +44 (0)7977 267231
GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 1/2] Add domain support for virtio channel

2010-02-18 Thread Matthew Booth
On 18/02/10 12:34, Daniel P. Berrange wrote:
 On Wed, Feb 17, 2010 at 05:11:00PM +, Matthew Booth wrote:
 Add support for virtio-serial by defining a new 'virtio' channel target type 
 and
 a virtio-serial controller. Allows the following to be specified in a domain:

 controller type='virtio-serial' index='0' max_ports='16' vectors='4'/
 channel type='pty'
   target type='virtio' name='org.linux-kvm.port.0'/
   address type='virtio-serial' controller='0' bus='0'/
 /channel

 * docs/schemas/domain.rng: Add virtio-serial controller and virtio channel 
 type.
 * src/conf/domain_conf.[ch]: Domain parsing/serialization for virtio-serial
  controller and virtio channel.
 * tests/qemuxml2xmltest.c
   tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.xml
: add domain xml parsing test
 * src/libvirt_private.syms
   src/qemu/qemu_conf.c: virDomainDefAddDiskControllers() renamed to
 virDomainDefAddImplicitControllers()
 ---
  docs/schemas/domain.rng|   71 +-
  src/conf/domain_conf.c |  234 
 +---
  src/conf/domain_conf.h |   25 ++-
  src/libvirt_private.syms   |2 +-
  src/qemu/qemu_conf.c   |2 +-
  .../qemuxml2argv-channel-virtio.xml|   35 +++
  tests/qemuxml2xmltest.c|1 +
  7 files changed, 320 insertions(+), 50 deletions(-)
  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.xml

 diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
 index 53b82ce..85df8b8 100644
 --- a/docs/schemas/domain.rng
 +++ b/docs/schemas/domain.rng
 @@ -523,16 +523,36 @@
/define
define name=controller
  element name=controller
 -  optional
 -attribute name=type
 -  choice
 -valuefdc/value
 -valueide/value
 -valuescsi/value
 -valuesata/value
 -  /choice
 -/attribute
 -  /optional
 +  choice
 +group
 +  optional
 +attribute name=type
 +  choice
 +valuefdc/value
 +valueide/value
 +valuescsi/value
 +valuesata/value
 +  /choice
 +/attribute
 +  /optional
 +/group
 +!-- virtio-serial can have 2 additional attributes --
 +group
 +  attribute name=type
 +valuevirtio-serial/value
 +  /attribute
 +  optional
 +attribute name=max_ports
 +  ref name=unsignedInt/
 +/attribute
 +  /optional
 +  optional
 +attribute name=vectors
 +  ref name=unsignedInt/
 +/attribute
 +  /optional
 
 What are these two new attributes doing ?  Can't we just auto-assign
 those values based on the configured channels later int he XML.

I'm not 100% sure what vectors does, however I believe this is a
resource usage tuning knob and therefore can't be inferred. max_ports we
could possibly default. However, virtio-serial also supports hot-plug,
although I haven't added libvirt support for it.

 +/group
 +  /choice
attribute name=index
  ref name=unsignedInt/
/attribute
 @@ -1139,12 +1159,25 @@
attribute name=port/
  /element
/define
 +  define name=virtioTarget
 +element name=target
 +  attribute name=type
 +  valuevirtio/value
 +  /attribute
 +  optional
 +attribute name=name/
 +  /optional
 +/element
 +  /define
define name=channel
  element name=channel
ref name=qemucdevSrcType/
interleave
  ref name=qemucdevSrcDef/
 -ref name=guestfwdTarget/
 +choice
 +  ref name=guestfwdTarget/
 +  ref name=virtioTarget/
 +/choice
  optional
ref name=address/
  /optional
 @@ -1269,6 +1302,16 @@
ref name=driveUnit/
  /attribute
/define
 +  define name=virtioserialaddress
 +attribute name=controller
 +  ref name=driveController/
 +/attribute
 +optional
 +  attribute name=bus
 +ref name=driveBus/
 +  /attribute
 +/optional
 +  /define
 
 What is the bus in the content of virtio serial ?

-device virtserialport,bus=channel0.0...

I've called 'channel0' the controller, and '0' the bus.

 @@ -916,7 +930,8 @@ void virDomainDefClearDeviceAliases(virDomainDefPtr def)
   */
  static int virDomainDeviceInfoFormat(virBufferPtr buf,
   virDomainDeviceInfoPtr info,
 - int flags)
 + int flags,
 + const char *indent)
 
 I'm not seeing why we need to pass 'indent' through here? The device info
 data should always

Re: [libvirt] [PATCH 2/2] Add QEMU support for virtio channel

2010-02-18 Thread Matthew Booth
On 18/02/10 12:39, Daniel P. Berrange wrote:
 On Wed, Feb 17, 2010 at 05:11:01PM +, Matthew Booth wrote:
 Support virtio-serial controller and virtio channel in QEMU backend. Will 
 output
 the following for virtio-serial controller:

 -device 
 virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x4,max_ports=16,vectors=4

 and the following for a virtio channel:

 -chardev pty,id=channel0 \
 -device 
 virtserialport,bus=virtio-serial0.0,chardev=channel0,name=org.linux-kvm.port.0

 * src/qemu/qemu_conf.c: Add argument output for virtio
 * tests/qemuxml2argvtest.c
   tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args
   : Add test for QEMU command line generation
 ---
  src/qemu/qemu_conf.c   |   91 
 +++-
  .../qemuxml2argv-channel-virtio.args   |1 +
  tests/qemuxml2argvtest.c   |1 +
  3 files changed, 92 insertions(+), 1 deletions(-)
  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args

 diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
 index 456ee34..110409d 100644
 --- a/src/qemu/qemu_conf.c
 +++ b/src/qemu/qemu_conf.c
 @@ -2168,7 +2168,6 @@ qemuAssignDevicePCISlots(virDomainDefPtr def, 
 qemuDomainPCIAddressSetPtr addrs)
  }
  for (i = 0; i  def-nchannels ; i++) {
  /* Nada - none are PCI based (yet) */
 -/* XXX virtio-serial will need one */
  }
  if (def-watchdog 
  def-watchdog-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
 @@ -2465,6 +2464,23 @@ qemuBuildControllerDevStr(virDomainControllerDefPtr 
 def)
  virBufferVSprintf(buf, ,id=scsi%d, def-idx);
  break;
  
 +case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
 +if (def-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
 +virBufferAddLit(buf, virtio-serial-pci);
 +} else {
 +virBufferAddLit(buf, virtio-serial);
 +}
 +virBufferVSprintf(buf, ,id=virtio-serial%d, def-idx);
 +if (def-opts.vioserial.max_ports != -1) {
 +virBufferVSprintf(buf, ,max_ports=%d,
 +  def-opts.vioserial.max_ports);
 +}
 +if (def-opts.vioserial.vectors != -1) {
 +virBufferVSprintf(buf, ,vectors=%d,
 +  def-opts.vioserial.vectors);
 +}
 +break;
 +
  /* We always get an IDE controller, whether we want it or not. */
  case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
  default:
 @@ -3830,6 +3846,79 @@ int qemudBuildCommandLine(virConnectPtr conn,
  }
  VIR_FREE(addr);
  ADD_ARG(devstr);
 +break;
 +
 +case VIR_DOMAIN_CHR_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(channel)))
 +goto error;
 +ADD_ARG(devstr);
 
 It would be desirable to put the stuff that follows this point, into
 a  qemuBuildVirtioSerialPortDevStr()  method, because the main 
 qemudBuildCommandLine() method is far too large  unwieldly these days.

Would this comment still stand if the code below was simplified to
hard-code alias?

 +
 +virBuffer virtiodev = VIR_BUFFER_INITIALIZER;
 +virBufferAddLit(virtiodev, virtserialport);
 +
 +if (channel-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
 +/* Check it's a virtio-serial address */
 +if (channel-info.type !=
 +VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL)
 +{
 +qemuReportError(VIR_ERR_INTERNAL_ERROR,
 +_(virtio serial device has invalid 
 +  address type));
 +virBufferFreeAndReset(virtiodev);
 +goto error;
 +}
 +
 +/* Look for the virtio-serial controller */
 +const char *vsalias = NULL;
 +int vs = 0;
 +int c;
 +for (c = 0; c  def-ncontrollers; c++) {
 +if (def-controllers[c]-type !=
 +VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL)
 +{
 +continue;
 +}
 +
 +if (vs == channel-info.addr.vioserial.controller) {
 +vsalias = def-controllers[c]-info.alias;
 +break;
 +}
 +
 +vs++;
 +}
 +
 +if (!vsalias) {
 +qemuReportError(VIR_ERR_INTERNAL_ERROR,
 +_(virtio serial device address

Re: [libvirt] [PATCH 2/2] Add QEMU support for virtio channel

2010-02-18 Thread Matthew Booth
On 18/02/10 14:11, Daniel P. Berrange wrote:
 On Thu, Feb 18, 2010 at 01:23:57PM +, Matthew Booth wrote:
 On 18/02/10 12:39, Daniel P. Berrange wrote:
 On Wed, Feb 17, 2010 at 05:11:01PM +, Matthew Booth wrote:
 Support virtio-serial controller and virtio channel in QEMU backend. Will 
 output
 the following for virtio-serial controller:

 -device 
 virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x4,max_ports=16,vectors=4

 and the following for a virtio channel:

 -chardev pty,id=channel0 \
 -device 
 virtserialport,bus=virtio-serial0.0,chardev=channel0,name=org.linux-kvm.port.0

 * src/qemu/qemu_conf.c: Add argument output for virtio
 * tests/qemuxml2argvtest.c
   tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args
   : Add test for QEMU command line generation
 ---
  src/qemu/qemu_conf.c   |   91 
 +++-
  .../qemuxml2argv-channel-virtio.args   |1 +
  tests/qemuxml2argvtest.c   |1 +
  3 files changed, 92 insertions(+), 1 deletions(-)
  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args

 diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
 index 456ee34..110409d 100644
 --- a/src/qemu/qemu_conf.c
 +++ b/src/qemu/qemu_conf.c
 @@ -2168,7 +2168,6 @@ qemuAssignDevicePCISlots(virDomainDefPtr def, 
 qemuDomainPCIAddressSetPtr addrs)
  }
  for (i = 0; i  def-nchannels ; i++) {
  /* Nada - none are PCI based (yet) */
 -/* XXX virtio-serial will need one */
  }
  if (def-watchdog 
  def-watchdog-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
 @@ -2465,6 +2464,23 @@ qemuBuildControllerDevStr(virDomainControllerDefPtr 
 def)
  virBufferVSprintf(buf, ,id=scsi%d, def-idx);
  break;
  
 +case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
 +if (def-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
 +virBufferAddLit(buf, virtio-serial-pci);
 +} else {
 +virBufferAddLit(buf, virtio-serial);
 +}
 +virBufferVSprintf(buf, ,id=virtio-serial%d, def-idx);
 +if (def-opts.vioserial.max_ports != -1) {
 +virBufferVSprintf(buf, ,max_ports=%d,
 +  def-opts.vioserial.max_ports);
 +}
 +if (def-opts.vioserial.vectors != -1) {
 +virBufferVSprintf(buf, ,vectors=%d,
 +  def-opts.vioserial.vectors);
 +}
 +break;
 +
  /* We always get an IDE controller, whether we want it or not. */
  case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
  default:
 @@ -3830,6 +3846,79 @@ int qemudBuildCommandLine(virConnectPtr conn,
  }
  VIR_FREE(addr);
  ADD_ARG(devstr);
 +break;
 +
 +case VIR_DOMAIN_CHR_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(channel)))
 +goto error;
 +ADD_ARG(devstr);

 It would be desirable to put the stuff that follows this point, into
 a  qemuBuildVirtioSerialPortDevStr()  method, because the main 
 qemudBuildCommandLine() method is far too large  unwieldly these days.

 Would this comment still stand if the code below was simplified to
 hard-code alias?
 
 Yep, because you'll want this method to exist if you ever add the
 hot-plug support, since that uses the exact same syntax as the 
 main -device arg these days. Which is nice :-)
 

 +
 +virBuffer virtiodev = VIR_BUFFER_INITIALIZER;
 +virBufferAddLit(virtiodev, virtserialport);
 +
 +if (channel-info.type != 
 VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
 +/* Check it's a virtio-serial address */
 +if (channel-info.type !=
 +VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL)
 +{
 +qemuReportError(VIR_ERR_INTERNAL_ERROR,
 +_(virtio serial device has invalid 
 +  address type));
 +virBufferFreeAndReset(virtiodev);
 +goto error;
 +}
 +
 +/* Look for the virtio-serial controller */
 +const char *vsalias = NULL;
 +int vs = 0;
 +int c;
 +for (c = 0; c  def-ncontrollers; c++) {
 +if (def-controllers[c]-type !=
 +VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL)
 +{
 +continue;
 +}
 +
 +if (vs == channel-info.addr.vioserial.controller) {
 +vsalias = def-controllers

Re: [libvirt] [PATCH 1/2] Add domain support for virtio channel

2010-02-18 Thread Matthew Booth
On 18/02/10 14:09, Daniel P. Berrange wrote:
 On Thu, Feb 18, 2010 at 01:16:02PM +, Matthew Booth wrote:
 On 18/02/10 12:34, Daniel P. Berrange wrote:
 On Wed, Feb 17, 2010 at 05:11:00PM +, Matthew Booth wrote:
 Add support for virtio-serial by defining a new 'virtio' channel target 
 type and
 a virtio-serial controller. Allows the following to be specified in a 
 domain:

 controller type='virtio-serial' index='0' max_ports='16' vectors='4'/
 channel type='pty'
   target type='virtio' name='org.linux-kvm.port.0'/
   address type='virtio-serial' controller='0' bus='0'/
 /channel

 * docs/schemas/domain.rng: Add virtio-serial controller and virtio channel 
 type.
 * src/conf/domain_conf.[ch]: Domain parsing/serialization for virtio-serial
  controller and virtio channel.
 * tests/qemuxml2xmltest.c
   tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.xml
: add domain xml parsing test
 * src/libvirt_private.syms
   src/qemu/qemu_conf.c: virDomainDefAddDiskControllers() renamed to
 virDomainDefAddImplicitControllers()
 ---
  docs/schemas/domain.rng|   71 +-
  src/conf/domain_conf.c |  234 
 +---
  src/conf/domain_conf.h |   25 ++-
  src/libvirt_private.syms   |2 +-
  src/qemu/qemu_conf.c   |2 +-
  .../qemuxml2argv-channel-virtio.xml|   35 +++
  tests/qemuxml2xmltest.c|1 +
  7 files changed, 320 insertions(+), 50 deletions(-)
  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.xml

 diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
 index 53b82ce..85df8b8 100644
 --- a/docs/schemas/domain.rng
 +++ b/docs/schemas/domain.rng
 @@ -523,16 +523,36 @@
/define
define name=controller
  element name=controller
 -  optional
 -attribute name=type
 -  choice
 -valuefdc/value
 -valueide/value
 -valuescsi/value
 -valuesata/value
 -  /choice
 -/attribute
 -  /optional
 +  choice
 +group
 +  optional
 +attribute name=type
 +  choice
 +valuefdc/value
 +valueide/value
 +valuescsi/value
 +valuesata/value
 +  /choice
 +/attribute
 +  /optional
 +/group
 +!-- virtio-serial can have 2 additional attributes --
 +group
 +  attribute name=type
 +valuevirtio-serial/value
 +  /attribute
 +  optional
 +attribute name=max_ports
 +  ref name=unsignedInt/
 +/attribute
 +  /optional
 +  optional
 +attribute name=vectors
 +  ref name=unsignedInt/
 +/attribute
 +  /optional

 What are these two new attributes doing ?  Can't we just auto-assign
 those values based on the configured channels later int he XML.

 I'm not 100% sure what vectors does, however I believe this is a
 resource usage tuning knob and therefore can't be inferred. max_ports we
 could possibly default. However, virtio-serial also supports hot-plug,
 although I haven't added libvirt support for it.
 
 Ok that's a good enough reason. Can we just call it 'ports' though.
 We don't use '_' in our XML attribute/element naming usually.
 
 @@ -1269,6 +1302,16 @@
ref name=driveUnit/
  /attribute
/define
 +  define name=virtioserialaddress
 +attribute name=controller
 +  ref name=driveController/
 +/attribute
 +optional
 +  attribute name=bus
 +ref name=driveBus/
 +  /attribute
 +/optional
 +  /define

 What is the bus in the content of virtio serial ?

 -device virtserialport,bus=channel0.0...

 I've called 'channel0' the controller, and '0' the bus.

 @@ -916,7 +930,8 @@ void virDomainDefClearDeviceAliases(virDomainDefPtr 
 def)
   */
  static int virDomainDeviceInfoFormat(virBufferPtr buf,
   virDomainDeviceInfoPtr info,
 - int flags)
 + int flags,
 + const char *indent)

 I'm not seeing why we need to pass 'indent' through here? The device info
 data should always be appearing at exactly the same place in all devices,
 specifically at  /domain/devices/[device type]/,  so indent level should
 always be the same.

 I could remove this. I was originally putting address elsewhere, which
 screwed up the indentation.
 
 Ok, your original code was definitely wrong then :-P
 

 @@ -1481,10 +1553,49 @@ virDomainControllerDefParseXML(xmlNodePtr node,
  if (virDomainDeviceInfoParseXML(node, def-info, flags)  0)
  goto error;
  
 +switch (def-type) {
 +case

[libvirt] [PATCH] Remove unused functions from domain_conf

2010-02-17 Thread Matthew Booth
Remove virDomainDevicePCIAddressEqual and virDomainDeviceDriveAddressEqual,
which are defined but not used anywhere.

* src/conf/domain_conf.[ch]: Remove virDomainDevicePCIAddressEqual and
 virDomainDeviceDriveAddressEqual.
---
 src/conf/domain_conf.c |   24 
 src/conf/domain_conf.h |4 
 2 files changed, 0 insertions(+), 28 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7f3df78..df35209 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -972,30 +972,6 @@ static int virDomainDeviceInfoFormat(virBufferPtr buf,
 
 #ifndef PROXY
 
-int virDomainDevicePCIAddressEqual(virDomainDevicePCIAddressPtr a,
-   virDomainDevicePCIAddressPtr b)
-{
-if (a-domain == b-domain 
-a-bus== b-bus 
-a-slot   == b-slot 
-a-function == b-function)
-return 1;
-
-return 0;
-}
-
-
-int virDomainDeviceDriveAddressEqual(virDomainDeviceDriveAddressPtr a,
- virDomainDeviceDriveAddressPtr b)
-{
-if (a-controller == b-controller 
-a-bus == b-bus 
-a-unit == b-unit)
-return 1;
-
-return 0;
-}
-
 
 static int
 virDomainDevicePCIAddressParseXML(xmlNodePtr node,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index d9b2f28..307d9b5 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -743,10 +743,6 @@ void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
 void virDomainVideoDefFree(virDomainVideoDefPtr def);
 void virDomainHostdevDefFree(virDomainHostdevDefPtr def);
 void virDomainDeviceDefFree(virDomainDeviceDefPtr def);
-int virDomainDevicePCIAddressEqual(virDomainDevicePCIAddressPtr a,
-   virDomainDevicePCIAddressPtr b);
-int virDomainDeviceDriveAddressEqual(virDomainDeviceDriveAddressPtr a,
- virDomainDeviceDriveAddressPtr b);
 int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info,
   int type);
 int virDomainDevicePCIAddressIsValid(virDomainDevicePCIAddressPtr addr);
-- 
1.6.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] libvirt XML format.

2010-02-17 Thread Matthew Booth
On 17/02/10 12:36, Kumar L Srikanth-B22348 wrote:
 Hi,

Hi Kumar,

 I have some doubts regarding libvirt XML format.
 Can anyone please let me know in detail, what is /source/ and
 /target/ tags in the libvirt XML format?

The best documentation is available here:
http://libvirt.org/formatdomain.html

If that's not enough, could you post an example of what you're trying to
do? Doesn't matter if it's wrong.

 Can I put '/' in the /target/ tag or are there any exceptions if I put
 '/' in that?

The domain XML is a valid XML document. Syntactically, you can put /
anywhere it would be valid in an XML document.

Matt
-- 
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

M:   +44 (0)7977 267231
GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] Fix typo in comment

2010-02-17 Thread Matthew Booth
* src/qemu/qemu_driver.c: Fix typo in comment
---
 src/qemu/qemu_driver.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 8766ca2..b4728e5 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2724,7 +2724,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
 }
 
 /*
- * Normally PCI addresses are assigned inhe virDomainCreate
+ * Normally PCI addresses are assigned in the virDomainCreate
  * or virDomainDefine methods. We might still need to assign
  * some here to cope with the question of upgrades. Regardless
  * we also need to populate the PCi address set cache for later
-- 
1.6.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] Fix whitespace in domain.rng

2010-02-17 Thread Matthew Booth
* src/schemas/domain.rng: Replace tabs with 8 spaces
---
 docs/schemas/domain.rng |   52 +++---
 1 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index a834705..1ac5943 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -538,7 +538,7 @@
 ref name=unsignedInt/
   /attribute
   optional
-   ref name=address/
+ref name=address/
   /optional
 /element
   /define
@@ -603,7 +603,7 @@
 /group
   /choice
   optional
-   ref name=address/
+ref name=address/
   /optional
 /element
   /define
@@ -762,7 +762,7 @@
 /element
   /optional
   optional
-   ref name=address/
+ref name=address/
   /optional
 /interleave
   /define
@@ -1015,7 +1015,7 @@
 /element
   /optional
   optional
-   ref name=address/
+ref name=address/
   /optional
 /interleave
   /define
@@ -1159,9 +1159,9 @@
   ref name=guestfwdTarget/
   ref name=virtioTarget/
 /choice
-   optional
- ref name=address/
-   /optional
+optional
+  ref name=address/
+/optional
   /interleave
 /element
   /define
@@ -1183,7 +1183,7 @@
 /attribute
   /optional
   optional
-   ref name=address/
+ref name=address/
   /optional
 /element
   /define
@@ -1212,12 +1212,12 @@
   group
 element name=source
   choice
-   group
+group
   ref name=usbproduct/
- optional
-   ref name=usbaddress/
- /optional
-   /group
+  optional
+ref name=usbaddress/
+  /optional
+/group
 ref name=usbaddress/
 element name=address
   ref name=pciaddress/
@@ -1276,7 +1276,7 @@
 /optional
 optional
   attribute name=bus
-   ref name=driveBus/
+ref name=driveBus/
   /attribute
 /optional
 attribute name=unit
@@ -1415,18 +1415,18 @@
   define name=address
 element name=address
   choice
-   group
- attribute name=type
-   valuepci/value
- /attribute
- ref name=pciaddress/
-   /group
-   group
- attribute name=type
-   valuedrive/value
- /attribute
- ref name=driveaddress/
-   /group
+group
+  attribute name=type
+valuepci/value
+  /attribute
+  ref name=pciaddress/
+/group
+group
+  attribute name=type
+valuedrive/value
+  /attribute
+  ref name=driveaddress/
+/group
   /choice
 /element
   /define
-- 
1.6.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] Fix whitespace in domain.rng

2010-02-17 Thread Matthew Booth
* src/schemas/domain.rng: Replace tabs with 8 spaces
---
 docs/schemas/domain.rng |   52 +++---
 1 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index 1ff0944..53b82ce 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -537,7 +537,7 @@
 ref name=unsignedInt/
   /attribute
   optional
-   ref name=address/
+ref name=address/
   /optional
 /element
   /define
@@ -602,7 +602,7 @@
 /group
   /choice
   optional
-   ref name=address/
+ref name=address/
   /optional
 /element
   /define
@@ -761,7 +761,7 @@
 /element
   /optional
   optional
-   ref name=address/
+ref name=address/
   /optional
 /interleave
   /define
@@ -1014,7 +1014,7 @@
 /element
   /optional
   optional
-   ref name=address/
+ref name=address/
   /optional
 /interleave
   /define
@@ -1145,9 +1145,9 @@
   interleave
 ref name=qemucdevSrcDef/
 ref name=guestfwdTarget/
-   optional
- ref name=address/
-   /optional
+optional
+  ref name=address/
+/optional
   /interleave
 /element
   /define
@@ -1169,7 +1169,7 @@
 /attribute
   /optional
   optional
-   ref name=address/
+ref name=address/
   /optional
 /element
   /define
@@ -1198,12 +1198,12 @@
   group
 element name=source
   choice
-   group
+group
   ref name=usbproduct/
- optional
-   ref name=usbaddress/
- /optional
-   /group
+  optional
+ref name=usbaddress/
+  /optional
+/group
 ref name=usbaddress/
 element name=address
   ref name=pciaddress/
@@ -1262,7 +1262,7 @@
 /optional
 optional
   attribute name=bus
-   ref name=driveBus/
+ref name=driveBus/
   /attribute
 /optional
 attribute name=unit
@@ -1401,18 +1401,18 @@
   define name=address
 element name=address
   choice
-   group
- attribute name=type
-   valuepci/value
- /attribute
- ref name=pciaddress/
-   /group
-   group
- attribute name=type
-   valuedrive/value
- /attribute
- ref name=driveaddress/
-   /group
+group
+  attribute name=type
+valuepci/value
+  /attribute
+  ref name=pciaddress/
+/group
+group
+  attribute name=type
+valuedrive/value
+  /attribute
+  ref name=driveaddress/
+/group
   /choice
 /element
   /define
-- 
1.6.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] virtio-serial support

2010-02-17 Thread Matthew Booth
These patches rebase my previously posted virtio-serial patches, add support for
max_ports and vectors, and allow multiple virtio-serial devices to be used. I
wasn't going to bother with the latter, however it turns out this can be useful
if the user wants more than 31 virtserialports.

N.B. These apply on top of 2 previously posted patches. Specifically Fix 
whitespace in domain.rng and Remove unused functions from domain_conf.

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 2/2] Add QEMU support for virtio channel

2010-02-17 Thread Matthew Booth
Support virtio-serial controller and virtio channel in QEMU backend. Will output
the following for virtio-serial controller:

-device 
virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x4,max_ports=16,vectors=4

and the following for a virtio channel:

-chardev pty,id=channel0 \
-device 
virtserialport,bus=virtio-serial0.0,chardev=channel0,name=org.linux-kvm.port.0

* src/qemu/qemu_conf.c: Add argument output for virtio
* tests/qemuxml2argvtest.c
  tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args
  : Add test for QEMU command line generation
---
 src/qemu/qemu_conf.c   |   91 +++-
 .../qemuxml2argv-channel-virtio.args   |1 +
 tests/qemuxml2argvtest.c   |1 +
 3 files changed, 92 insertions(+), 1 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 456ee34..110409d 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -2168,7 +2168,6 @@ qemuAssignDevicePCISlots(virDomainDefPtr def, 
qemuDomainPCIAddressSetPtr addrs)
 }
 for (i = 0; i  def-nchannels ; i++) {
 /* Nada - none are PCI based (yet) */
-/* XXX virtio-serial will need one */
 }
 if (def-watchdog 
 def-watchdog-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
@@ -2465,6 +2464,23 @@ qemuBuildControllerDevStr(virDomainControllerDefPtr def)
 virBufferVSprintf(buf, ,id=scsi%d, def-idx);
 break;
 
+case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
+if (def-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
+virBufferAddLit(buf, virtio-serial-pci);
+} else {
+virBufferAddLit(buf, virtio-serial);
+}
+virBufferVSprintf(buf, ,id=virtio-serial%d, def-idx);
+if (def-opts.vioserial.max_ports != -1) {
+virBufferVSprintf(buf, ,max_ports=%d,
+  def-opts.vioserial.max_ports);
+}
+if (def-opts.vioserial.vectors != -1) {
+virBufferVSprintf(buf, ,vectors=%d,
+  def-opts.vioserial.vectors);
+}
+break;
+
 /* We always get an IDE controller, whether we want it or not. */
 case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
 default:
@@ -3830,6 +3846,79 @@ int qemudBuildCommandLine(virConnectPtr conn,
 }
 VIR_FREE(addr);
 ADD_ARG(devstr);
+break;
+
+case VIR_DOMAIN_CHR_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(channel)))
+goto error;
+ADD_ARG(devstr);
+
+virBuffer virtiodev = VIR_BUFFER_INITIALIZER;
+virBufferAddLit(virtiodev, virtserialport);
+
+if (channel-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
+/* Check it's a virtio-serial address */
+if (channel-info.type !=
+VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL)
+{
+qemuReportError(VIR_ERR_INTERNAL_ERROR,
+_(virtio serial device has invalid 
+  address type));
+virBufferFreeAndReset(virtiodev);
+goto error;
+}
+
+/* Look for the virtio-serial controller */
+const char *vsalias = NULL;
+int vs = 0;
+int c;
+for (c = 0; c  def-ncontrollers; c++) {
+if (def-controllers[c]-type !=
+VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL)
+{
+continue;
+}
+
+if (vs == channel-info.addr.vioserial.controller) {
+vsalias = def-controllers[c]-info.alias;
+break;
+}
+
+vs++;
+}
+
+if (!vsalias) {
+qemuReportError(VIR_ERR_INTERNAL_ERROR,
+_(virtio serial device address controller 

+  does not exist));
+virBufferFreeAndReset(virtiodev);
+goto error;
+}
+
+virBufferVSprintf(virtiodev, ,bus=%s.%d,
+  vsalias, channel-info.addr.vioserial.bus);
+}
+
+virBufferVSprintf(virtiodev, ,chardev=%s, channel-info.alias);
+if (channel-target.name) {
+virBufferVSprintf(virtiodev, ,name=%s, 
channel-target.name);

[libvirt] [PATCH 1/2] Add domain support for virtio channel

2010-02-17 Thread Matthew Booth
Add support for virtio-serial by defining a new 'virtio' channel target type and
a virtio-serial controller. Allows the following to be specified in a domain:

controller type='virtio-serial' index='0' max_ports='16' vectors='4'/
channel type='pty'
  target type='virtio' name='org.linux-kvm.port.0'/
  address type='virtio-serial' controller='0' bus='0'/
/channel

* docs/schemas/domain.rng: Add virtio-serial controller and virtio channel type.
* src/conf/domain_conf.[ch]: Domain parsing/serialization for virtio-serial
 controller and virtio channel.
* tests/qemuxml2xmltest.c
  tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.xml
   : add domain xml parsing test
* src/libvirt_private.syms
  src/qemu/qemu_conf.c: virDomainDefAddDiskControllers() renamed to
virDomainDefAddImplicitControllers()
---
 docs/schemas/domain.rng|   71 +-
 src/conf/domain_conf.c |  234 +---
 src/conf/domain_conf.h |   25 ++-
 src/libvirt_private.syms   |2 +-
 src/qemu/qemu_conf.c   |2 +-
 .../qemuxml2argv-channel-virtio.xml|   35 +++
 tests/qemuxml2xmltest.c|1 +
 7 files changed, 320 insertions(+), 50 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.xml

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index 53b82ce..85df8b8 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -523,16 +523,36 @@
   /define
   define name=controller
 element name=controller
-  optional
-attribute name=type
-  choice
-valuefdc/value
-valueide/value
-valuescsi/value
-valuesata/value
-  /choice
-/attribute
-  /optional
+  choice
+group
+  optional
+attribute name=type
+  choice
+valuefdc/value
+valueide/value
+valuescsi/value
+valuesata/value
+  /choice
+/attribute
+  /optional
+/group
+!-- virtio-serial can have 2 additional attributes --
+group
+  attribute name=type
+valuevirtio-serial/value
+  /attribute
+  optional
+attribute name=max_ports
+  ref name=unsignedInt/
+/attribute
+  /optional
+  optional
+attribute name=vectors
+  ref name=unsignedInt/
+/attribute
+  /optional
+/group
+  /choice
   attribute name=index
 ref name=unsignedInt/
   /attribute
@@ -1139,12 +1159,25 @@
   attribute name=port/
 /element
   /define
+  define name=virtioTarget
+element name=target
+  attribute name=type
+  valuevirtio/value
+  /attribute
+  optional
+attribute name=name/
+  /optional
+/element
+  /define
   define name=channel
 element name=channel
   ref name=qemucdevSrcType/
   interleave
 ref name=qemucdevSrcDef/
-ref name=guestfwdTarget/
+choice
+  ref name=guestfwdTarget/
+  ref name=virtioTarget/
+/choice
 optional
   ref name=address/
 /optional
@@ -1269,6 +1302,16 @@
   ref name=driveUnit/
 /attribute
   /define
+  define name=virtioserialaddress
+attribute name=controller
+  ref name=driveController/
+/attribute
+optional
+  attribute name=bus
+ref name=driveBus/
+  /attribute
+/optional
+  /define
   !--
   Devices attached to a domain.
 --
@@ -1413,6 +1456,12 @@
   /attribute
   ref name=driveaddress/
 /group
+group
+  attribute name=type
+valuevirtio-serial/value
+  /attribute
+  ref name=virtioserialaddress/
+/group
   /choice
 /element
   /define
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 59fd251..58f353b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -93,7 +93,8 @@ VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST,
 VIR_ENUM_IMPL(virDomainDeviceAddress, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST,
   none,
   pci,
-  drive);
+  drive,
+  virtio-serial);
 
 VIR_ENUM_IMPL(virDomainDisk, VIR_DOMAIN_DISK_TYPE_LAST,
   block,
@@ -125,7 +126,8 @@ VIR_ENUM_IMPL(virDomainController, 
VIR_DOMAIN_CONTROLLER_TYPE_LAST,
   ide,
   fdc,
   scsi,
-  sata)
+  sata,
+  virtio-serial)
 
 VIR_ENUM_IMPL(virDomainFS, VIR_DOMAIN_FS_TYPE_LAST,
   mount,
@@ -150,7 +152,8 @@ VIR_ENUM_IMPL(virDomainChrTarget, 
VIR_DOMAIN_CHR_TARGET_TYPE_LAST,
   

Re: [libvirt] [PATCH] Remove unused functions from domain_conf

2010-02-17 Thread Matthew Booth
On 17/02/10 17:08, Daniel Veillard wrote:
   Hum, virDomainDevicePCIAddressEqual is actually exposed in
 src/libvirt_private.syms so that would have to be cleaned up there too.
 If no ongoing patches is needing them I'm fine removeing those,

Hadn't spotted that. Attached new patch which touches
src/libvirt_private.syms.

Matt
-- 
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

M:   +44 (0)7977 267231
GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490
From 5612c7c7a5969a84cc97f50ad2bdf9070ef95210 Mon Sep 17 00:00:00 2001
From: Matthew Booth mbo...@redhat.com
Date: Wed, 17 Feb 2010 13:25:41 +
Subject: [PATCH] Remove unused functions from domain_conf

Remove virDomainDevicePCIAddressEqual and virDomainDeviceDriveAddressEqual,
which are defined but not used anywhere.

* src/conf/domain_conf.[ch]
  src/libvirt_private.syms: Remove virDomainDevicePCIAddressEqual and
virDomainDeviceDriveAddressEqual.
---
 src/conf/domain_conf.c   |   24 
 src/conf/domain_conf.h   |4 
 src/libvirt_private.syms |1 -
 3 files changed, 0 insertions(+), 29 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 561fa22..59fd251 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -966,30 +966,6 @@ static int virDomainDeviceInfoFormat(virBufferPtr buf,
 
 #ifndef PROXY
 
-int virDomainDevicePCIAddressEqual(virDomainDevicePCIAddressPtr a,
-   virDomainDevicePCIAddressPtr b)
-{
-if (a-domain == b-domain 
-a-bus== b-bus 
-a-slot   == b-slot 
-a-function == b-function)
-return 1;
-
-return 0;
-}
-
-
-int virDomainDeviceDriveAddressEqual(virDomainDeviceDriveAddressPtr a,
- virDomainDeviceDriveAddressPtr b)
-{
-if (a-controller == b-controller 
-a-bus == b-bus 
-a-unit == b-unit)
-return 1;
-
-return 0;
-}
-
 
 static int
 virDomainDevicePCIAddressParseXML(xmlNodePtr node,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 231d8c8..782af95 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -740,10 +740,6 @@ void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
 void virDomainVideoDefFree(virDomainVideoDefPtr def);
 void virDomainHostdevDefFree(virDomainHostdevDefPtr def);
 void virDomainDeviceDefFree(virDomainDeviceDefPtr def);
-int virDomainDevicePCIAddressEqual(virDomainDevicePCIAddressPtr a,
-   virDomainDevicePCIAddressPtr b);
-int virDomainDeviceDriveAddressEqual(virDomainDeviceDriveAddressPtr a,
- virDomainDeviceDriveAddressPtr b);
 int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info,
   int type);
 int virDomainDevicePCIAddressIsValid(virDomainDevicePCIAddressPtr addr);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index aa826d6..4dd7e98 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -179,7 +179,6 @@ virDomainObjListInit;
 virDomainObjListDeinit;
 virDomainObjRef;
 virDomainObjUnref;
-virDomainDevicePCIAddressEqual;
 virDomainDeviceAddressIsValid;
 virDomainDevicePCIAddressIsValid;
 virDomainDeviceInfoIsSet;
-- 
1.6.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH] Clarify lack of generated IDE -device string in QEMU driver

2010-01-28 Thread Matthew Booth
The QEMU driver contained code to generate a -device string for piix4-ide, but
wasn't using it. This was intentional. This change removes the string generation
and adds a comment explaining why no -device is necessary.

* src/qemu/qemu_conf.c: Remove VIR_DOMAIN_CONTROLLER_TYPE_IDE handler in
qemuBuildControllerDevStr(). Add comments.
---
 src/qemu/qemu_conf.c |   16 
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index f4a6c08..1c4f326 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -2121,11 +2121,8 @@ qemuBuildControllerDevStr(virDomainControllerDefPtr def)
 virBufferVSprintf(buf, ,id=scsi%d, def-idx);
 break;
 
+/* We always get an IDE controller, whether we want it or not. */
 case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
-virBufferAddLit(buf, piix4-ide);
-virBufferVSprintf(buf, ,id=ide%d, def-idx);
-break;
-
 default:
 goto error;
 }
@@ -3141,16 +3138,19 @@ int qemudBuildCommandLine(virConnectPtr conn,
 
 if (qemuCmdFlags  QEMUD_CMD_FLAG_DEVICE) {
 for (i = 0 ; i  def-ncontrollers ; i++) {
-char *scsi;
-if (def-controllers[i]-type != VIR_DOMAIN_CONTROLLER_TYPE_SCSI)
+/* We don't add an explicit IDE controller because the provided
+ * PIIX4 device already includes one. It isn't possible to remove
+ * the PIIX4. */
+if (def-controllers[i]-type == VIR_DOMAIN_CONTROLLER_TYPE_IDE)
 continue;
 
 ADD_ARG_LIT(-device);
 
-if (!(scsi = qemuBuildControllerDevStr(def-controllers[i])))
+char *devstr;
+if (!(devstr = qemuBuildControllerDevStr(def-controllers[i])))
 goto no_memory;
 
-ADD_ARG(scsi);
+ADD_ARG(devstr);
 }
 }
 
-- 
1.6.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] Clarify lack of generated IDE -device string in QEMU driver

2010-01-28 Thread Matthew Booth
On 28/01/10 10:57, Daniel P. Berrange wrote:
 On Thu, Jan 28, 2010 at 10:35:48AM +, Matthew Booth wrote:
 The QEMU driver contained code to generate a -device string for piix4-ide, 
 but
 wasn't using it. This was intentional. This change removes the string 
 generation
 and adds a comment explaining why no -device is necessary.

 * src/qemu/qemu_conf.c: Remove VIR_DOMAIN_CONTROLLER_TYPE_IDE handler in
 qemuBuildControllerDevStr(). Add comments.
 ---
  src/qemu/qemu_conf.c |   16 
  1 files changed, 8 insertions(+), 8 deletions(-)

 diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
 index f4a6c08..1c4f326 100644
 --- a/src/qemu/qemu_conf.c
 +++ b/src/qemu/qemu_conf.c
 @@ -2121,11 +2121,8 @@ qemuBuildControllerDevStr(virDomainControllerDefPtr 
 def)
  virBufferVSprintf(buf, ,id=scsi%d, def-idx);
  break;
  
 +/* We always get an IDE controller, whether we want it or not. */
  case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
 -virBufferAddLit(buf, piix4-ide);
 -virBufferVSprintf(buf, ,id=ide%d, def-idx);
 -break;
 -
  default:
  goto error;
  }
 @@ -3141,16 +3138,19 @@ int qemudBuildCommandLine(virConnectPtr conn,
  
  if (qemuCmdFlags  QEMUD_CMD_FLAG_DEVICE) {
  for (i = 0 ; i  def-ncontrollers ; i++) {
 -char *scsi;
 -if (def-controllers[i]-type != 
 VIR_DOMAIN_CONTROLLER_TYPE_SCSI)
 +/* We don't add an explicit IDE controller because the provided
 + * PIIX4 device already includes one. It isn't possible to 
 remove
 + * the PIIX4. */
 +if (def-controllers[i]-type == VIR_DOMAIN_CONTROLLER_TYPE_IDE)
  continue;
 
 That's not quite right because you changed the conditional to blacklist IDE
 insteasd of whitelisting SCSI. This means that FDC now falls through. We do
 not need to explicitly add the FDC, since that is also provided automatically
 on the ISA bridge that's behind the PIIX4.

Ok. Still think a blacklist is more appropriate, though. I'll add FDC to
the blacklist. Are there any more?

Matt
-- 
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

M:   +44 (0)7977 267231
GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] Clarify why some controllers don't generate -device string in QEMU driver

2010-01-28 Thread Matthew Booth
The QEMU driver contained code to generate a -device string for piix4-ide, but
wasn't using it. This change removes this string generation. It also adds a
comment explaining why IDE and FDC controllers don't generate -device strings.

The change also generates an error if a sata controller is specified for a QEMU
domain, as this isn't supported.

* src/qemu/qemu_conf.c: Remove VIR_DOMAIN_CONTROLLER_TYPE_IDE handler in
qemuBuildControllerDevStr(). Ignore IDE and FDC
controllers. Error if SATA controller is discovered. Add
comments.
---
 src/qemu/qemu_conf.c |   16 
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index f4a6c08..1c4f326 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -2121,11 +2121,8 @@ qemuBuildControllerDevStr(virDomainControllerDefPtr def)
 virBufferVSprintf(buf, ,id=scsi%d, def-idx);
 break;
 
+/* We always get an IDE controller, whether we want it or not. */
 case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
-virBufferAddLit(buf, piix4-ide);
-virBufferVSprintf(buf, ,id=ide%d, def-idx);
-break;
-
 default:
 goto error;
 }
@@ -3141,16 +3138,19 @@ int qemudBuildCommandLine(virConnectPtr conn,
 
 if (qemuCmdFlags  QEMUD_CMD_FLAG_DEVICE) {
 for (i = 0 ; i  def-ncontrollers ; i++) {
-char *scsi;
-if (def-controllers[i]-type != VIR_DOMAIN_CONTROLLER_TYPE_SCSI)
+/* We don't add an explicit IDE controller because the provided
+ * PIIX4 device already includes one. It isn't possible to remove
+ * the PIIX4. */
+if (def-controllers[i]-type == VIR_DOMAIN_CONTROLLER_TYPE_IDE)
 continue;
 
 ADD_ARG_LIT(-device);
 
-if (!(scsi = qemuBuildControllerDevStr(def-controllers[i])))
+char *devstr;
+if (!(devstr = qemuBuildControllerDevStr(def-controllers[i])))
 goto no_memory;
 
-ADD_ARG(scsi);
+ADD_ARG(devstr);
 }
 }
 
-- 
1.6.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] Clarify why some controllers don't generate -device string in QEMU driver

2010-01-28 Thread Matthew Booth
The QEMU driver contained code to generate a -device string for piix4-ide, but
wasn't using it. This change removes this string generation. It also adds a
comment explaining why IDE and FDC controllers don't generate -device strings.

The change also generates an error if a sata controller is specified for a QEMU
domain, as this isn't supported.

* src/qemu/qemu_conf.c: Remove VIR_DOMAIN_CONTROLLER_TYPE_IDE handler in
qemuBuildControllerDevStr(). Ignore IDE and FDC
controllers. Error if SATA controller is discovered. Add
comments.
---
 src/qemu/qemu_conf.c |   26 ++
 1 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index f4a6c08..3b7793f 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -2121,11 +2121,8 @@ qemuBuildControllerDevStr(virDomainControllerDefPtr def)
 virBufferVSprintf(buf, ,id=scsi%d, def-idx);
 break;
 
+/* We always get an IDE controller, whether we want it or not. */
 case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
-virBufferAddLit(buf, piix4-ide);
-virBufferVSprintf(buf, ,id=ide%d, def-idx);
-break;
-
 default:
 goto error;
 }
@@ -3141,16 +3138,29 @@ int qemudBuildCommandLine(virConnectPtr conn,
 
 if (qemuCmdFlags  QEMUD_CMD_FLAG_DEVICE) {
 for (i = 0 ; i  def-ncontrollers ; i++) {
-char *scsi;
-if (def-controllers[i]-type != VIR_DOMAIN_CONTROLLER_TYPE_SCSI)
+virDomainControllerDefPtr cont = def-controllers[i];
+
+/* We don't add an explicit IDE or FD controller because the
+ * provided PIIX4 device already includes one. It isn't possible to
+ * remove the PIIX4. */
+if (cont-type == VIR_DOMAIN_CONTROLLER_TYPE_IDE ||
+cont-type == VIR_DOMAIN_CONTROLLER_TYPE_FDC)
 continue;
 
+/* QEMU doesn't implement a SATA driver */
+if (cont-type == VIR_DOMAIN_CONTROLLER_TYPE_SATA) {
+qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT,
+ %s, _(SATA is not supported with this QEMU 
binary));
+goto error;
+}
+
 ADD_ARG_LIT(-device);
 
-if (!(scsi = qemuBuildControllerDevStr(def-controllers[i])))
+char *devstr;
+if (!(devstr = qemuBuildControllerDevStr(def-controllers[i])))
 goto no_memory;
 
-ADD_ARG(scsi);
+ADD_ARG(devstr);
 }
 }
 
-- 
1.6.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 3/3] Add QEMU support for virtio channel

2010-01-28 Thread Matthew Booth
Support virtio-serial controller and virtio channel in QEMU backend. Will output
the following for virtio-serial controller:

-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x4

and the following for a virtio channel:

-chardev pty,id=channel0 \
-device virtserialport,chardev=channel0,name=org.linux-kvm.port.0

* src/qemu/qemu_conf.c: Add argument output for virtio
* tests/qemuxml2argvtest.c
  tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args
  : Add test for QEMU command line generation
---
 src/qemu/qemu_conf.c   |   51 +++-
 .../qemuxml2argv-channel-virtio.args   |1 +
 tests/qemuxml2argvtest.c   |1 +
 3 files changed, 52 insertions(+), 1 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 0c67334..73c6e28 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1681,7 +1681,6 @@ qemuAssignDevicePCISlots(virDomainDefPtr def)
 }
 for (i = 0; i  def-nchannels ; i++) {
 /* Nada - none are PCI based (yet) */
-/* XXX virtio-serial will need one */
 }
 if (def-watchdog) {
 qemuAssignDevicePCISlot(def-watchdog-info, nextslot++);
@@ -2121,6 +2120,15 @@ qemuBuildControllerDevStr(virDomainControllerDefPtr def)
 virBufferVSprintf(buf, ,id=scsi%d, def-idx);
 break;
 
+case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
+if (def-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
+virBufferAddLit(buf, virtio-serial-pci);
+} else {
+virBufferAddLit(buf, virtio-serial);
+}
+virBufferVSprintf(buf, ,id=virtio-serial%d, def-idx);
+break;
+
 /* We always get an IDE controller, whether we want it or not. */
 case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
 default:
@@ -3508,6 +3516,47 @@ int qemudBuildCommandLine(virConnectPtr conn,
 }
 
 ADD_ARG(virBufferContentAndReset(buf));
+break;
+
+case VIR_DOMAIN_CHR_TARGET_TYPE_VIRTIO:
+if (!(qemuCmdFlags  QEMUD_CMD_FLAG_DEVICE)) {
+qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT, %s,
+_(virtio channel requires QEMU to support -device));
+goto error;
+}
+
+qemudBuildCommandLineChrDevChardevStr(channel, buf);
+if (virBufferError(buf))
+goto error;
+
+ADD_ARG_LIT(-chardev);
+ADD_ARG(virBufferContentAndReset(buf));
+
+virBufferVSprintf(buf, virtserialport,chardev=%s,
+  channel-info.alias);
+if (channel-target.virtio.name) {
+virBufferVSprintf(buf, ,name=%s,
+  channel-target.virtio.name);
+}
+if (channel-target.virtio.byteLimit) {
+virBufferVSprintf(buf, ,byte_limit=%s,
+  channel-target.virtio.byteLimit);
+}
+if (channel-target.virtio.guestByteLimit) {
+virBufferVSprintf(buf, ,guest_byte_limit=%s,
+  channel-target.virtio.guestByteLimit);
+}
+if (channel-target.virtio.cacheBuffers) {
+virBufferVSprintf(buf, ,cache_buffers=%s,
+  channel-target.virtio.cacheBuffers);
+}
+if (virBufferError(buf))
+goto error;
+
+ADD_ARG_LIT(-device);
+ADD_ARG(virBufferContentAndReset(buf));
+
+break;
 }
 }
 
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args 
b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args
new file mode 100644
index 000..ded97d1
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-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 -nodefaults -monitor 
unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -device 
virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x4 -hda 
/dev/HostVG/QEMUGuest1 -chardev pty,id=channel0 -device 
virtserialport,chardev=channel0,name=org.linux-kvm.port.0,byte_limit=1048576,guest_byte_limit=1048576,cache_buffers=1
 -usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index fc237c2..f6b33c2 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -297,6 +297,7 @@ mymain(int argc, char **argv)
 DO_TEST(console-compat-chardev, 
QEMUD_CMD_FLAG_CHARDEV|QEMUD_CMD_FLAG_DEVICE);
 
 DO_TEST(channel-guestfwd, QEMUD_CMD_FLAG_CHARDEV|QEMUD_CMD_FLAG_DEVICE);
+DO_TEST(channel-virtio, QEMUD_CMD_FLAG_DEVICE);
 
 DO_TEST(watchdog, 0);
 DO_TEST(watchdog-device, QEMUD_CMD_FLAG_DEVICE);
-- 
1.6.6

--
libvir-list 

[libvirt] [PATCH 1/3] Clarify why some controllers don't generate -device string in QEMU driver

2010-01-28 Thread Matthew Booth
The QEMU driver contained code to generate a -device string for piix4-ide, but
wasn't using it. This change removes this string generation. It also adds a
comment explaining why IDE and FDC controllers don't generate -device strings.

The change also generates an error if a sata controller is specified for a QEMU
domain, as this isn't supported.

* src/qemu/qemu_conf.c: Remove VIR_DOMAIN_CONTROLLER_TYPE_IDE handler in
qemuBuildControllerDevStr(). Ignore IDE and FDC
controllers. Error if SATA controller is discovered. Add
comments.
---
 src/qemu/qemu_conf.c |   26 ++
 1 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index f4a6c08..3b7793f 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -2121,11 +2121,8 @@ qemuBuildControllerDevStr(virDomainControllerDefPtr def)
 virBufferVSprintf(buf, ,id=scsi%d, def-idx);
 break;
 
+/* We always get an IDE controller, whether we want it or not. */
 case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
-virBufferAddLit(buf, piix4-ide);
-virBufferVSprintf(buf, ,id=ide%d, def-idx);
-break;
-
 default:
 goto error;
 }
@@ -3141,16 +3138,29 @@ int qemudBuildCommandLine(virConnectPtr conn,
 
 if (qemuCmdFlags  QEMUD_CMD_FLAG_DEVICE) {
 for (i = 0 ; i  def-ncontrollers ; i++) {
-char *scsi;
-if (def-controllers[i]-type != VIR_DOMAIN_CONTROLLER_TYPE_SCSI)
+virDomainControllerDefPtr cont = def-controllers[i];
+
+/* We don't add an explicit IDE or FD controller because the
+ * provided PIIX4 device already includes one. It isn't possible to
+ * remove the PIIX4. */
+if (cont-type == VIR_DOMAIN_CONTROLLER_TYPE_IDE ||
+cont-type == VIR_DOMAIN_CONTROLLER_TYPE_FDC)
 continue;
 
+/* QEMU doesn't implement a SATA driver */
+if (cont-type == VIR_DOMAIN_CONTROLLER_TYPE_SATA) {
+qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT,
+ %s, _(SATA is not supported with this QEMU 
binary));
+goto error;
+}
+
 ADD_ARG_LIT(-device);
 
-if (!(scsi = qemuBuildControllerDevStr(def-controllers[i])))
+char *devstr;
+if (!(devstr = qemuBuildControllerDevStr(def-controllers[i])))
 goto no_memory;
 
-ADD_ARG(scsi);
+ADD_ARG(devstr);
 }
 }
 
-- 
1.6.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 2/3] Add domain support for virtio channel

2010-01-28 Thread Matthew Booth
Add support for virtio-serial by defining a new 'virtio' channel target type and
a virtio-serial controller. Allows the following to be specified in a domain:

controller type='virtio-serial' index='0'/
channel type='pty'
  target type='virtio' name='org.linux-kvm.port.0'/
/channel

* docs/schemas/domain.rng: Add virtio-serial controller and virtio channel type.
* src/conf/domain_conf.[ch]: Domain parsing/serialization for virtio-serial
 controller and virtio channel.
* tests/qemuxml2xmltest.c
  tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.xml
   : add domain xml parsing test
* src/libvirt_private.syms
  src/qemu/qemu_conf.c: virDomainDefAddDiskControllers() renamed to
virDomainDefAddImplicitControllers()
---
 docs/schemas/domain.rng|   25 -
 src/conf/domain_conf.c |  124 +---
 src/conf/domain_conf.h |   10 ++-
 src/libvirt_private.syms   |2 +-
 src/qemu/qemu_conf.c   |2 +-
 .../qemuxml2argv-channel-virtio.xml|   28 +
 tests/qemuxml2xmltest.c|1 +
 7 files changed, 173 insertions(+), 19 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.xml

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index 827ff6f..a3247b9 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -530,6 +530,7 @@
 valueide/value
 valuescsi/value
 valuesata/value
+valuevirtio-serial/value
   /choice
 /attribute
   /optional
@@ -1120,12 +1121,34 @@
   attribute name=port/
 /element
   /define
+  define name=virtioTarget
+element name=target
+  attribute name=type
+  valuevirtio/value
+  /attribute
+  optional
+attribute name=name/
+  /optional
+  optional
+attribute name=bytelimit/
+  /optional
+  optional
+attribute name=guestbytelimit/
+  /optional
+  optional
+attribute name=cachebuffers/
+  /optional
+/element
+  /define
   define name=channel
 element name=channel
   ref name=qemucdevSrcType/
   interleave
 ref name=qemucdevSrcDef/
-ref name=guestfwdTarget/
+choice
+  ref name=guestfwdTarget/
+  ref name=virtioTarget/
+/choice
optional
  ref name=address/
/optional
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e548d1d..3b96086 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -124,7 +124,8 @@ VIR_ENUM_IMPL(virDomainController, 
VIR_DOMAIN_CONTROLLER_TYPE_LAST,
   ide,
   fdc,
   scsi,
-  sata)
+  sata,
+  virtio-serial)
 
 VIR_ENUM_IMPL(virDomainFS, VIR_DOMAIN_FS_TYPE_LAST,
   mount,
@@ -148,7 +149,8 @@ VIR_ENUM_IMPL(virDomainChrTarget, 
VIR_DOMAIN_CHR_TARGET_TYPE_LAST,
   parallel,
   serial,
   console,
-  guestfwd)
+  guestfwd,
+  virtio)
 
 VIR_ENUM_IMPL(virDomainChr, VIR_DOMAIN_CHR_TYPE_LAST,
   null,
@@ -449,6 +451,13 @@ void virDomainChrDefFree(virDomainChrDefPtr def)
 case VIR_DOMAIN_CHR_TARGET_TYPE_GUESTFWD:
 VIR_FREE(def-target.addr);
 break;
+
+case VIR_DOMAIN_CHR_TARGET_TYPE_VIRTIO:
+VIR_FREE(def-target.virtio.name);
+VIR_FREE(def-target.virtio.byteLimit);
+VIR_FREE(def-target.virtio.guestByteLimit);
+VIR_FREE(def-target.virtio.cacheBuffers);
+break;
 }
 
 switch (def-type) {
@@ -1460,7 +1469,7 @@ virDomainControllerDefParseXML(virConnectPtr conn,
 
 type = virXMLPropString(node, type);
 if (type) {
-if ((def-type = virDomainDiskBusTypeFromString(type))  0) {
+if ((def-type = virDomainControllerTypeFromString(type))  0) {
 virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
  _(unknown disk controller type '%s'), type);
 goto error;
@@ -2081,6 +2090,48 @@ virDomainChrDefParseXML(virConnectPtr conn,
 virSocketSetPort(def-target.addr, port);
 break;
 
+case VIR_DOMAIN_CHR_TARGET_TYPE_VIRTIO:
+def-target.virtio.name
+= virXMLPropString(cur, name);
+def-target.virtio.byteLimit
+= virXMLPropString(cur, bytelimit);
+def-target.virtio.guestByteLimit
+= virXMLPropString(cur, guestbytelimit);
+def-target.virtio.cacheBuffers
+= virXMLPropString(cur, cachebuffers);
+
+/* Ensure bytelimit and guestbytelimit are positive 
integers
+ 

[libvirt] [PATCH 2/2] Add QEMU support for virtio channel

2010-01-28 Thread Matthew Booth
Support virtio-serial controller and virtio channel in QEMU backend. Will output
the following for virtio-serial controller:

-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x4

and the following for a virtio channel:

-chardev pty,id=channel0 \
-device virtserialport,chardev=channel0,name=org.linux-kvm.port.0

* src/qemu/qemu_conf.c: Add argument output for virtio
* tests/qemuxml2argvtest.c
  tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args
  : Add test for QEMU command line generation
---
 src/qemu/qemu_conf.c   |   38 +++-
 .../qemuxml2argv-channel-virtio.args   |1 +
 tests/qemuxml2argvtest.c   |1 +
 3 files changed, 39 insertions(+), 1 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 0c67334..7123827 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1681,7 +1681,6 @@ qemuAssignDevicePCISlots(virDomainDefPtr def)
 }
 for (i = 0; i  def-nchannels ; i++) {
 /* Nada - none are PCI based (yet) */
-/* XXX virtio-serial will need one */
 }
 if (def-watchdog) {
 qemuAssignDevicePCISlot(def-watchdog-info, nextslot++);
@@ -2121,6 +2120,15 @@ qemuBuildControllerDevStr(virDomainControllerDefPtr def)
 virBufferVSprintf(buf, ,id=scsi%d, def-idx);
 break;
 
+case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
+if (def-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
+virBufferAddLit(buf, virtio-serial-pci);
+} else {
+virBufferAddLit(buf, virtio-serial);
+}
+virBufferVSprintf(buf, ,id=virtio-serial%d, def-idx);
+break;
+
 /* We always get an IDE controller, whether we want it or not. */
 case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
 default:
@@ -3508,6 +3516,34 @@ int qemudBuildCommandLine(virConnectPtr conn,
 }
 
 ADD_ARG(virBufferContentAndReset(buf));
+break;
+
+case VIR_DOMAIN_CHR_TARGET_TYPE_VIRTIO:
+if (!(qemuCmdFlags  QEMUD_CMD_FLAG_DEVICE)) {
+qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT, %s,
+_(virtio channel requires QEMU to support -device));
+goto error;
+}
+
+qemudBuildCommandLineChrDevChardevStr(channel, buf);
+if (virBufferError(buf))
+goto error;
+
+ADD_ARG_LIT(-chardev);
+ADD_ARG(virBufferContentAndReset(buf));
+
+virBufferVSprintf(buf, virtserialport,chardev=%s,
+  channel-info.alias);
+if (channel-target.name) {
+virBufferVSprintf(buf, ,name=%s, channel-target.name);
+}
+if (virBufferError(buf))
+goto error;
+
+ADD_ARG_LIT(-device);
+ADD_ARG(virBufferContentAndReset(buf));
+
+break;
 }
 }
 
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args 
b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args
new file mode 100644
index 000..6cb2a8f
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-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 -nodefaults -monitor 
unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -device 
virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x4 -hda 
/dev/HostVG/QEMUGuest1 -chardev pty,id=channel0 -device 
virtserialport,chardev=channel0,name=org.linux-kvm.port.0 -usb -device 
virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index fc237c2..f6b33c2 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -297,6 +297,7 @@ mymain(int argc, char **argv)
 DO_TEST(console-compat-chardev, 
QEMUD_CMD_FLAG_CHARDEV|QEMUD_CMD_FLAG_DEVICE);
 
 DO_TEST(channel-guestfwd, QEMUD_CMD_FLAG_CHARDEV|QEMUD_CMD_FLAG_DEVICE);
+DO_TEST(channel-virtio, QEMUD_CMD_FLAG_DEVICE);
 
 DO_TEST(watchdog, 0);
 DO_TEST(watchdog-device, QEMUD_CMD_FLAG_DEVICE);
-- 
1.6.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH UPDATE] Add support for virtio channel

2010-01-28 Thread Matthew Booth
Amit pointed out that byte_limit, guest_byte_limit and cache_buffers are now
gone. They are removed in these updated patches.

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 1/2] Add domain support for virtio channel

2010-01-28 Thread Matthew Booth
Add support for virtio-serial by defining a new 'virtio' channel target type and
a virtio-serial controller. Allows the following to be specified in a domain:

controller type='virtio-serial' index='0'/
channel type='pty'
  target type='virtio' name='org.linux-kvm.port.0'/
/channel

* docs/schemas/domain.rng: Add virtio-serial controller and virtio channel type.
* src/conf/domain_conf.[ch]: Domain parsing/serialization for virtio-serial
 controller and virtio channel.
* tests/qemuxml2xmltest.c
  tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.xml
   : add domain xml parsing test
* src/libvirt_private.syms
  src/qemu/qemu_conf.c: virDomainDefAddDiskControllers() renamed to
virDomainDefAddImplicitControllers()
---
 docs/schemas/domain.rng|   16 -
 src/conf/domain_conf.c |   71 +++
 src/conf/domain_conf.h |5 +-
 src/libvirt_private.syms   |2 +-
 src/qemu/qemu_conf.c   |2 +-
 .../qemuxml2argv-channel-virtio.xml|   28 
 tests/qemuxml2xmltest.c|1 +
 7 files changed, 106 insertions(+), 19 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.xml

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index 827ff6f..9509e80 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -530,6 +530,7 @@
 valueide/value
 valuescsi/value
 valuesata/value
+valuevirtio-serial/value
   /choice
 /attribute
   /optional
@@ -1120,12 +1121,25 @@
   attribute name=port/
 /element
   /define
+  define name=virtioTarget
+element name=target
+  attribute name=type
+  valuevirtio/value
+  /attribute
+  optional
+attribute name=name/
+  /optional
+/element
+  /define
   define name=channel
 element name=channel
   ref name=qemucdevSrcType/
   interleave
 ref name=qemucdevSrcDef/
-ref name=guestfwdTarget/
+choice
+  ref name=guestfwdTarget/
+  ref name=virtioTarget/
+/choice
optional
  ref name=address/
/optional
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e548d1d..c514164 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -124,7 +124,8 @@ VIR_ENUM_IMPL(virDomainController, 
VIR_DOMAIN_CONTROLLER_TYPE_LAST,
   ide,
   fdc,
   scsi,
-  sata)
+  sata,
+  virtio-serial)
 
 VIR_ENUM_IMPL(virDomainFS, VIR_DOMAIN_FS_TYPE_LAST,
   mount,
@@ -148,7 +149,8 @@ VIR_ENUM_IMPL(virDomainChrTarget, 
VIR_DOMAIN_CHR_TARGET_TYPE_LAST,
   parallel,
   serial,
   console,
-  guestfwd)
+  guestfwd,
+  virtio)
 
 VIR_ENUM_IMPL(virDomainChr, VIR_DOMAIN_CHR_TYPE_LAST,
   null,
@@ -449,6 +451,10 @@ void virDomainChrDefFree(virDomainChrDefPtr def)
 case VIR_DOMAIN_CHR_TARGET_TYPE_GUESTFWD:
 VIR_FREE(def-target.addr);
 break;
+
+case VIR_DOMAIN_CHR_TARGET_TYPE_VIRTIO:
+VIR_FREE(def-target.name);
+break;
 }
 
 switch (def-type) {
@@ -1460,7 +1466,7 @@ virDomainControllerDefParseXML(virConnectPtr conn,
 
 type = virXMLPropString(node, type);
 if (type) {
-if ((def-type = virDomainDiskBusTypeFromString(type))  0) {
+if ((def-type = virDomainControllerTypeFromString(type))  0) {
 virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
  _(unknown disk controller type '%s'), type);
 goto error;
@@ -2081,6 +2087,10 @@ virDomainChrDefParseXML(virConnectPtr conn,
 virSocketSetPort(def-target.addr, port);
 break;
 
+case VIR_DOMAIN_CHR_TARGET_TYPE_VIRTIO:
+def-target.name = virXMLPropString(cur, name);
+break;
+
 default:
 virDomainReportError(conn, VIR_ERR_XML_ERROR,
  _(unexpected target type type %u),
@@ -3640,12 +3650,6 @@ static virDomainDefPtr 
virDomainDefParseXML(virConnectPtr conn,
 }
 VIR_FREE(nodes);
 
-/* Auto-add any further disk controllers implied by declared disk
- * elements, but not present as controller elements
- */
-if (virDomainDefAddDiskControllers(def)  0)
-goto error;
-
 /* analysis of the filesystems */
 if ((n = virXPathNodeSet(conn, ./devices/filesystem, ctxt, nodes))  0) 
{
 virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
@@ -3970,6 +3974,11 @@ static virDomainDefPtr 
virDomainDefParseXML(virConnectPtr conn,
 goto error;
 }
 
+/* 

[libvirt] [PATCH] Add missing sata controller type to domain.rng

2010-01-27 Thread Matthew Booth
* docs/schemas/domain.rng: Add sata controller type
---
 docs/schemas/domain.rng |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index 49b57eb..827ff6f 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -529,6 +529,7 @@
 valuefdc/value
 valueide/value
 valuescsi/value
+valuesata/value
   /choice
 /attribute
   /optional
-- 
1.6.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] Cannot use console with 0.7.5, error: internal error no assigned pty for device serial0

2010-01-15 Thread Matthew Booth
On 15/01/10 09:18, Marc Haber wrote:
 [my apologies for this re-post. I stupidly managed to hide the first
 instance of this mail away in an unrelated patch-thread and am thus
 afraid that the people who could have answered didn't see it]
 
 Hi,
 
 I have one test host running Debian unstable (kernel 2.6.32.3), and I
 would like to virtualize on it using KVM and virsh. Debian unstable
 has libvirt 0.7.5.
 
 On this host, I cannot start any KVM domain using console with these
 XML parts:
 
 serial type='pty'
   target port='0'/
 /serial
 console type='pty'
   target port='0'/
 /console
 
 When I try virsh start $domain, I get the error message:
 
 error: internal error no assigned pty for device serial0
 
 When I remove the serial and console stanza, the machine starts up.
 This is the configuration documented everywhere. At first, I suspected
 a change in the configuration syntax and filed Debian bug #565145, But
 on the #virt IRC channel, people suggested that there was a change in
 libvirt parsing KVM's output, which may be a genuine bug breaking the
 console.
 
 Is this already a known issue? Can I do anything to help debugging?

Hi, Marc,

Could you please post the full domain XML, and the QEMU command line it
generated? You can get the latter from
/var/log/libvirt/qemu/domain.log. Can you also post the versions of
qemu and libvirt?

This should let me see where it's going wrong.

Thanks,

Matt
-- 
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

M:   +44 (0)7977 267231
GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] Using ESX domain XML for V2V

2010-01-14 Thread Matthew Booth
I'm trying to use the ESX driver to extract metadata from ESX in an 
easily digestible form for driving V2V. I've noticed the domain XML 
seems to be missing a few bits:


features/
graphics/
input/

serial/ and console/ are also missing, but that could well be 
because they aren't present.


Is this intentional? Should I be assuming some of the above because it's 
ESX, or is this an omission?


Thanks,

Matt
--
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

M:   +44 (0)7977 267231
GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] Cleanup temporary #define after use

2009-12-14 Thread Matthew Booth
* src/qemu/qemu_driver.c: #undef LOOKUP_PTYS after use
---
 src/qemu/qemu_driver.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 7e55c23..4567a66 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1436,6 +1436,7 @@ qemudFindCharDevicePTYsMonitor(virConnectPtr conn,
 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);
+#undef LOOKUP_PTYS
 
 return 0;
 }
-- 
1.6.5.2

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] Fix parsing of 'info chardev' line endings

2009-12-14 Thread Matthew Booth
This change makes the 'info chardev' parser ignore any trailing whitespace on a
line. This fixes a specific problem handling a '\r\n' line ending.

* src/qemu/qemu_monitor_text.c: Ignore trailing whitespace in 'info chardev'
  output.
---
 src/qemu/qemu_monitor_text.c |   26 +-
 1 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 0cb9ea6..4fd8c4a 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -1622,15 +1622,26 @@ int qemuMonitorTextGetPtyPaths(qemuMonitorPtr mon,
 goto cleanup;
 }
 
-char *pos = reply;  /* The current start of searching */
-char *end = pos + strlen(reply);/* The end of the reply string */
+char *pos;  /* The current start of searching */
+char *next = reply; /* The start of the next line */
 char *eol;   /* The character which ends the current line 
*/
+char *end = reply + strlen(reply);  /* The end of the reply string */
+
+while (next) {
+pos = next;
 
-while (pos  end) {
 /* Split the output into lines */
 eol = memchr(pos, '\n', end - pos);
-if (eol == NULL)
+if (eol == NULL) {
 eol = end;
+next = NULL;
+} else {
+next = eol + 1;
+}
+
+/* Ignore all whitespace immediately before eol */
+while (eol  pos  c_isspace(*(eol-1)))
+eol -= 1;
 
 /* Look for 'filename=pty:' */
 #define NEEDLE filename=pty:
@@ -1638,13 +1649,13 @@ int qemuMonitorTextGetPtyPaths(qemuMonitorPtr mon,
 
 /* If it's not there we can ignore this line */
 if (!needle)
-goto next;
+continue;
 
 /* id is everthing from the beginning of the line to the ':'
  * find ':' and turn it into a terminator */
 char *colon = memchr(pos, ':', needle - pos);
 if (colon == NULL)
-goto next;
+continue;
 *colon = '\0';
 char *id = pos;
 
@@ -1664,9 +1675,6 @@ int qemuMonitorTextGetPtyPaths(qemuMonitorPtr mon,
 goto cleanup;
 }
 #undef NEEDLE
-
-next:
-pos = eol + 1;
 }
 
 ret = 0;
-- 
1.6.5.2

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] Out of band channels

2009-12-11 Thread Matthew Booth
A libvirt client can connect to libvirt on a remote host. However, on 
its own this doesn't give the client a usable level of access. The 
reason for this is that libvirt doesn't expose some critical management 
interfaces. For QEMU this amounts to pretty much anything provided 
directly by the QEMU process, including:


* VNC console [1]
* Any character device [2]

I'm undecided as to whether access to underlying storage falls into this 
bucket. It would certainly be convenient in certain circumstances.


This means, for example that I need out of band access to:

* See a graphical console
* Connect to a serial console
* Connect to a guest channel

As these are fairly fundamental operations, I wonder if there has been 
any thought towards creating tunnels over a libvirt connection.


In the first instance, I think this would require a generic method to 
multiplex multiple streams over a single remote connection. This would 
obviously be a significant protocol change. Would a messaging protocol, 
AMQP for instance, be a good candidate here?


Secondly, I think interfaces which currently create local resources 
should have a default which is managed by libvirt itself. So you'd have:


serial
  target port='0'/
/serial

or

serial type='managed'
  target port='0'/
/serial

This would cause libvirt to create whichever host-side chardev is most 
convenient to it and connect itself. The API would then expose read and 
write APIs for the named connection. e.g:


virDomainFoo foo;[3]
if = virDomainGetFoo(domain, serial0);
bytesIn = virDomainFooRead(foo, buf, sizeof(buf));

A client application could expose this in a variety of ways locally.

Matt

[1] There's an open RFE for this one: 
https://bugzilla.redhat.com/show_bug.cgi?id=526953


[2] e.g.
virsh # console RHEL3.FV.64.IDE
error: Cannot connect to a remote console device

[3] What would you call it?
--
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

M:   +44 (0)7977 267231
GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] Fix owner and group in example volume XML

2009-12-11 Thread Matthew Booth
The owner and group in the documentation examples were confusingly given as
'0744'. They should be numeric uid and gid. Changed the examples to use the
default uid and gid assigned to qemu in F12.

* docs/formatstorage.html.in: Change example owner and group in volume XML
---
 docs/formatstorage.html.in |   16 
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in
index ccf5a91..5c41c39 100644
--- a/docs/formatstorage.html.in
+++ b/docs/formatstorage.html.in
@@ -119,8 +119,8 @@
 lt;targetgt;
   lt;pathgt;/dev/disk/by-pathlt;/pathgt;
   lt;permissionsgt;
-lt;ownergt;0744lt;/ownergt;
-lt;groupgt;0744lt;/groupgt;
+lt;ownergt;107lt;/ownergt;
+lt;groupgt;107lt;/groupgt;
 lt;modegt;0744lt;/modegt;
 lt;labelgt;virt_image_tlt;/labelgt;
   lt;/permissionsgt;
@@ -244,8 +244,8 @@
   lt;pathgt;/var/lib/virt/images/sparse.imglt;/pathgt;
   lt;format type='qcow2'/gt;
   lt;permissionsgt;
-lt;ownergt;0744lt;/ownergt;
-lt;groupgt;0744lt;/groupgt;
+lt;ownergt;107lt;/ownergt;
+lt;groupgt;107lt;/groupgt;
 lt;modegt;0744lt;/modegt;
 lt;labelgt;virt_image_tlt;/labelgt;
   lt;/permissionsgt;
@@ -294,8 +294,8 @@
   lt;pathgt;/var/lib/virt/images/master.imglt;/pathgt;
   lt;formatgt;rawlt;/formatgt;
   lt;permissionsgt;
-lt;ownergt;0744lt;/ownergt;
-lt;groupgt;0744lt;/groupgt;
+lt;ownergt;107lt;/ownergt;
+lt;groupgt;107lt;/groupgt;
 lt;modegt;0744lt;/modegt;
 lt;labelgt;virt_image_tlt;/labelgt;
   lt;/permissionsgt;
@@ -368,8 +368,8 @@
 lt;targetgt;
   lt;pathgt;/var/lib/virt/images/sparse.imglt;/pathgt;
   lt;permissionsgt;
-lt;ownergt;0744lt;/ownergt;
-lt;groupgt;0744lt;/groupgt;
+lt;ownergt;107lt;/ownergt;
+lt;groupgt;107lt;/groupgt;
 lt;modegt;0744lt;/modegt;
 lt;labelgt;virt_image_tlt;/labelgt;
   lt;/permissionsgt;
-- 
1.6.5.2

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


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

2009-12-10 Thread Matthew Booth
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   |  108 +---
 .../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, 445 insertions(+), 17 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 a25fac6..86172c6 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1863,17 +1863,37 @@ int qemudBuildCommandLine(virConnectPtr conn,
 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;
 }
 

[libvirt] [PATCH 2/3] Extract the assigned pty device for channels

2009-12-10 Thread Matthew Booth
* src/qemu/qemu_driver.c: Parse pty devices for channels
---
 src/qemu/qemu_driver.c |   10 ++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2fb059d..c1feb0f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1439,6 +1439,16 @@ qemudFindCharDevicePTYs(virConnectPtr conn,
 }
 }
 
+/* then the channel devices */
+for (i = 0 ; i  vm-def-nchannels ; i++) {
+virDomainChrDefPtr chr = vm-def-channels[i];
+if (chr-type == VIR_DOMAIN_CHR_TYPE_PTY) {
+if ((ret = qemudExtractTTYPath(conn, output, offset,
+   chr-data.file.path)) != 0)
+return ret;
+}
+}
+
 return 0;
 }
 
-- 
1.6.5.2

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 3/3] Get QEMU pty paths from the monitor

2009-12-10 Thread Matthew Booth
This change makes the QEMU driver get pty paths from the output of the monitor
'info chardev' command. This output is structured, and contains both the name of
the device and the path on the same line. This is considerably more reliable
than parsing the startup log output, which requires the parsing code to know
which order QEMU will print pty information in.

Note that we still need to parse the log output as the monitor itself may be on
a pty. This should be rare, however, and the new code will replace all pty paths
parsed by the log output method once the monitor is available.

* src/qemu/qemu_monitor.(c|h) src/qemu_monitor_text.(c|h): Implement
  qemuMonitorGetPtyPaths().
* src/qemu/qemu_driver.c: Get pty path information using
  qemuMonitorGetPtyPaths().
---
 src/qemu/qemu_driver.c   |   68 +++-
 src/qemu/qemu_monitor.c  |9 +
 src/qemu/qemu_monitor.h  |3 ++
 src/qemu/qemu_monitor_text.c |   71 ++
 src/qemu/qemu_monitor_text.h |4 ++
 5 files changed, 153 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index c1feb0f..6f1fc1a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1407,6 +1407,40 @@ qemudExtractTTYPath(virConnectPtr conn,
 }
 
 static int
+qemudFindCharDevicePTYsMonitor(virConnectPtr conn,
+   virDomainObjPtr vm,
+   virHashTablePtr paths)
+{
+int i;
+
+#define LOOKUP_PTYS(array, arraylen, idprefix) \
+for (i = 0 ; i  (arraylen) ; i++) { \
+virDomainChrDefPtr chr = (array)[i]; \
+if (chr-type == VIR_DOMAIN_CHR_TYPE_PTY) { \
+char id[16]; \
+\
+if (snprintf(id, sizeof(id), idprefix %i, i) = sizeof(id)) \
+return -1; \
+\
+const char *path = (const char *) virHashLookup(paths, id); \
+if (path == NULL) { \
+qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, \
+ _(no assigned pty for device %s), id); \
+return -1; \
+} \
+\
+chr-data.file.path = strdup(path); \
+} \
+}
+
+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);
+
+return 0;
+}
+
+static int
 qemudFindCharDevicePTYs(virConnectPtr conn,
 virDomainObjPtr vm,
 const char *output,
@@ -1452,6 +1486,11 @@ qemudFindCharDevicePTYs(virConnectPtr conn,
 return 0;
 }
 
+static void qemudFreePtyPath(void *payload, const char *name ATTRIBUTE_UNUSED)
+{
+free(payload);
+}
+
 static int
 qemudWaitForMonitor(virConnectPtr conn,
 struct qemud_driver* driver,
@@ -1459,7 +1498,7 @@ qemudWaitForMonitor(virConnectPtr conn,
 {
 char buf[4096]; /* Plenty of space to get startup greeting */
 int logfd;
-int ret;
+int ret = -1;
 
 if ((logfd = qemudLogReadFD(conn, driver-logDir, vm-def-name, pos))
  0)
@@ -1485,7 +1524,32 @@ qemudWaitForMonitor(virConnectPtr conn,
 if (qemuConnectMonitor(vm)  0)
 return -1;
 
-return 0;
+/* Try to get the pty path mappings again via the monitor. This is much 
more
+ * reliable if it's available.
+ * Note that the monitor itself can be on a pty, so we still need to try 
the
+ * log output method. */
+virHashTablePtr paths = virHashCreate(0);
+if (paths == NULL) {
+virReportOOMError(NULL);
+goto cleanup;
+}
+
+qemuDomainObjEnterMonitor(vm);
+qemuDomainObjPrivatePtr priv = vm-privateData;
+ret = qemuMonitorGetPtyPaths(priv-mon, paths);
+qemuDomainObjExitMonitor(vm);
+
+VIR_DEBUG(qemuMonitorGetPtyPaths returned %i, ret);
+if (ret == 0) {
+ret = qemudFindCharDevicePTYsMonitor(conn, vm, paths);
+}
+
+cleanup:
+if (paths) {
+virHashFree(paths, qemudFreePtyPath);
+}
+
+return ret;
 }
 
 static int
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 103cf28..750e3e6 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -1267,3 +1267,12 @@ int qemuMonitorRemoveHostNetwork(qemuMonitorPtr mon,
 ret = qemuMonitorTextRemoveHostNetwork(mon, vlan, netname);
 return ret;
 }
+
+int qemuMonitorGetPtyPaths(qemuMonitorPtr mon,
+   virHashTablePtr paths)
+{
+DEBUG(mon=%p, fd=%d,
+  mon, mon-fd);
+
+return qemuMonitorTextGetPtyPaths(mon, paths);
+}
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 8b1e3a3..db00b26 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -28,6 +28,7 @@
 #include internal.h
 
 #include domain_conf.h
+#include hash.h
 
 typedef struct _qemuMonitor qemuMonitor;
 typedef qemuMonitor *qemuMonitorPtr;
@@ -272,5 +273,7 @@ int 

Re: [libvirt] [PATCH] Add test for legacy console ... tty= syntax

2009-11-25 Thread Matthew Booth

On 25/11/09 11:25, Daniel P. Berrange wrote:

On Mon, Nov 23, 2009 at 01:48:30PM +, Matthew Booth wrote:

* tests/qemuxml2argvtest.c: Test legacy syntax for QEMU argument generation
* tests/qemuxml2argvdata/qemuxml2argv-console-legacy.(xml|args): Add test data


This test doesn't seem to test anything we're not already testing ?


Where's it currently tested? I couldn't see it. I also ran a make check 
with this test in place before and after the recent tty= fix. It failed 
before and succeeded afterwards.


That said, I'm not entirely sure what the console-compat test is 
testing. Is it possible that the test was supposed to be in there?


Matt
--
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

M:   +44 (0)7977 267231
GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] Improve the reliability of pty path parsing

2009-11-23 Thread Matthew Booth
The following are improve the reliability of libvirt's mapping of character
devices to pty paths.

When qemu starts up it will output one or more lines of the form:

char device redirected to /dev/pts/5

Note that the character device this refers to is not indicated, so the only way
to match this up is by knowing the order they're written in. This is not a
well-defined interface, and is therefore voodoo-magic.

The current code works against current versions of QEMU. However, when using the
-chardev syntax of newer QEMU, the output order changes (putting chardev first).
The first patch works by making all character devices use -chardev if it's
available. As well as being a better syntax, this makes the output of the
redirection lines again match the order they're specified on the command line.

The second patch uses this ordering to parse the ptys for channel devices from
the log output.

The third patch (almost) obsoletes the log output parsing method. If QEMU's
monitor supports 'info chardev', this gives structured information about
character devices, including pty mappings. The log output parsing method is
still required because QEMU may not support info chardev, and because the
monitor itself can be on a pty. The danger of the third patch is that it will
fix errors in the log output parsing code, which may then bitrot.

Matt

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


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

2009-11-23 Thread Matthew Booth
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 

[libvirt] [PATCH 2/3] Extract the assigned pty device for channels

2009-11-23 Thread Matthew Booth
* src/qemu/qemu_driver.c: Parse pty devices for channels
---
 src/qemu/qemu_driver.c |   10 ++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2c5086b..ebf44b0 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1271,6 +1271,16 @@ qemudFindCharDevicePTYs(virConnectPtr conn,
 }
 }
 
+/* then the channel devices */
+for (i = 0 ; i  vm-def-nchannels ; i++) {
+virDomainChrDefPtr chr = vm-def-channels[i];
+if (chr-type == VIR_DOMAIN_CHR_TYPE_PTY) {
+if ((ret = qemudExtractTTYPath(conn, output, offset,
+   chr-data.file.path)) != 0)
+return ret;
+}
+}
+
 return 0;
 }
 
-- 
1.6.5.2

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 3/3] Get QEMU pty paths from the monitor

2009-11-23 Thread Matthew Booth
This change makes the QEMU driver get pty paths from the output of the monitor
'info chardev' command. This output is structured, and contains both the name of
the device and the path on the same line. This is considerably more reliable
than parsing the startup log output, which requires the parsing code to know
which order QEMU will print pty information in.

Note that we still need to parse the log output as the monitor itself may be on
a pty. This should be rare, however, and the new code will replace all pty paths
parsed by the log output method once the monitor is available.

* src/qemu/qemu_monitor.(c|h) src/qemu_monitor_text.(c|h): Implement
  qemuMonitorGetPtyPaths().
* src/qemu/qemu_driver.c: Get pty path information using
  qemuMonitorGetPtyPaths().
---
 src/qemu/qemu_driver.c   |   68 +++-
 src/qemu/qemu_monitor.c  |9 +
 src/qemu/qemu_monitor.h  |3 ++
 src/qemu/qemu_monitor_text.c |   71 ++
 src/qemu/qemu_monitor_text.h |4 ++
 5 files changed, 153 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ebf44b0..90dd9cd 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1239,6 +1239,40 @@ qemudExtractTTYPath(virConnectPtr conn,
 }
 
 static int
+qemudFindCharDevicePTYsMonitor(virConnectPtr conn,
+   virDomainObjPtr vm,
+   virHashTablePtr paths)
+{
+int i;
+
+#define LOOKUP_PTYS(array, arraylen, idprefix) \
+for (i = 0 ; i  (arraylen) ; i++) { \
+virDomainChrDefPtr chr = (array)[i]; \
+if (chr-type == VIR_DOMAIN_CHR_TYPE_PTY) { \
+char id[16]; \
+\
+if (snprintf(id, sizeof(id), idprefix %i, i) = sizeof(id)) \
+return -1; \
+\
+const char *path = (const char *) virHashLookup(paths, id); \
+if (path == NULL) { \
+qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, \
+ _(no assigned pty for device %s), id); \
+return -1; \
+} \
+\
+chr-data.file.path = strdup(path); \
+} \
+}
+
+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);
+
+return 0;
+}
+
+static int
 qemudFindCharDevicePTYs(virConnectPtr conn,
 virDomainObjPtr vm,
 const char *output,
@@ -1284,6 +1318,11 @@ qemudFindCharDevicePTYs(virConnectPtr conn,
 return 0;
 }
 
+static void qemudFreePtyPath(void *payload, const char *name ATTRIBUTE_UNUSED)
+{
+free(payload);
+}
+
 static int
 qemudWaitForMonitor(virConnectPtr conn,
 struct qemud_driver* driver,
@@ -1291,7 +1330,7 @@ qemudWaitForMonitor(virConnectPtr conn,
 {
 char buf[4096]; /* Plenty of space to get startup greeting */
 int logfd;
-int ret;
+int ret = -1;
 
 if ((logfd = qemudLogReadFD(conn, driver-logDir, vm-def-name, pos))
  0)
@@ -1317,7 +1356,32 @@ qemudWaitForMonitor(virConnectPtr conn,
 if (qemuConnectMonitor(vm)  0)
 return -1;
 
-return 0;
+/* Try to get the pty path mappings again via the monitor. This is much 
more
+ * reliable if it's available.
+ * Note that the monitor itself can be on a pty, so we still need to try 
the
+ * log output method. */
+virHashTablePtr paths = virHashCreate(0);
+if (paths == NULL) {
+virReportOOMError(NULL);
+goto cleanup;
+}
+
+qemuDomainObjEnterMonitor(vm);
+qemuDomainObjPrivatePtr priv = vm-privateData;
+ret = qemuMonitorGetPtyPaths(priv-mon, paths);
+qemuDomainObjExitMonitor(vm);
+
+VIR_DEBUG(qemuMonitorGetPtyPaths returned %i, ret);
+if (ret == 0) {
+ret = qemudFindCharDevicePTYsMonitor(conn, vm, paths);
+}
+
+cleanup:
+if (paths) {
+virHashFree(paths, qemudFreePtyPath);
+}
+
+return ret;
 }
 
 static int
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index f0ef81b..92f005a 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -904,3 +904,12 @@ int qemuMonitorRemoveHostNetwork(qemuMonitorPtr mon,
 
 return qemuMonitorTextRemoveHostNetwork(mon, vlan, netname);
 }
+
+int qemuMonitorGetPtyPaths(qemuMonitorPtr mon,
+   virHashTablePtr paths)
+{
+DEBUG(mon=%p, fd=%d,
+  mon, mon-fd);
+
+return qemuMonitorTextGetPtyPaths(mon, paths);
+}
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 71688cb..dc14bbe 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -28,6 +28,7 @@
 #include internal.h
 
 #include domain_conf.h
+#include hash.h
 
 typedef struct _qemuMonitor qemuMonitor;
 typedef qemuMonitor *qemuMonitorPtr;
@@ -244,5 +245,7 @@ int 

[libvirt] [PATCH] Add test for legacy console ... tty= syntax

2009-11-23 Thread Matthew Booth
* tests/qemuxml2argvtest.c: Test legacy syntax for QEMU argument generation
* tests/qemuxml2argvdata/qemuxml2argv-console-legacy.(xml|args): Add test data
---
 .../qemuxml2argv-console-legacy.args   |1 +
 .../qemuxml2argv-console-legacy.xml|   29 
 tests/qemuxml2argvtest.c   |1 +
 3 files changed, 31 insertions(+), 0 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-legacy.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-legacy.xml

diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-legacy.args 
b/tests/qemuxml2argvdata/qemuxml2argv-console-legacy.args
new file mode 100644
index 000..fd42462
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-console-legacy.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-legacy.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-console-legacy.xml
new file mode 100644
index 000..68d86ba
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-console-legacy.xml
@@ -0,0 +1,29 @@
+domain type='qemu'
+  nameQEMUGuest1/name
+  uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid
+  memory219200/memory
+  currentMemory219200/currentMemory
+  vcpu1/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'/
+/disk
+serial type='pty'
+  target port='0'/
+/serial
+console type='pty' tty='/dev/pts/8'
+  source path='/dev/pts/8'/
+  target port='0'/
+/console
+  /devices
+/domain
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index c948379..233b3ae 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -268,6 +268,7 @@ mymain(int argc, char **argv)
 DO_TEST(serial-many, 0);
 DO_TEST(parallel-tcp, 0);
 DO_TEST(console-compat, 0);
+DO_TEST(console-legacy, 0);
 
 DO_TEST(channel-guestfwd, QEMUD_CMD_FLAG_CHARDEV);
 
-- 
1.6.5.2

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] Make QEMU driver use -chardev everywhere when it's available

2009-11-17 Thread Matthew Booth

On 16/11/09 13:30, Daniel P. Berrange wrote:

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index c807688..4f4b3db 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1844,12 +1844,36 @@ 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) {
+char id[16];
+
+if (snprintf(id, sizeof(id), monitor%i, i)  sizeof(id))
+goto error;


This is using 'i' uninitialized I believe. Its a little overkill to do
a printf here at all since there's only ever a single monitor called
'monitor0'


Whoops, cut/paste error. It doesn't sound like this is going to be 
merged immediately, so I'll keep the fix locally for the moment.


Thanks,

Matt
--
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

M:   +44 (0)7977 267231
GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] Fix typo in error message

2009-11-17 Thread Matthew Booth
* src/qemu/qemu_monitor_text.c: Fix typo
* po/*.po: Update typo in translations
---
 po/af.po |2 +-
 po/am.po |2 +-
 po/ar.po |2 +-
 po/as.po |2 +-
 po/be.po |2 +-
 po/bg.po |2 +-
 po/bn.po |2 +-
 po/bn_IN.po  |2 +-
 po/bs.po |2 +-
 po/ca.po |2 +-
 po/cs.po |2 +-
 po/cy.po |2 +-
 po/da.po |2 +-
 po/de.po |2 +-
 po/el.po |2 +-
 po/en_GB.po  |2 +-
 po/es.po |2 +-
 po/et.po |2 +-
 po/eu_ES.po  |2 +-
 po/fa.po |2 +-
 po/fi.po |2 +-
 po/fr.po |2 +-
 po/gl.po |2 +-
 po/gu.po |2 +-
 po/he.po |2 +-
 po/hi.po |2 +-
 po/hr.po |2 +-
 po/hu.po |2 +-
 po/hy.po |2 +-
 po/id.po |2 +-
 po/is.po |2 +-
 po/it.po |2 +-
 po/ja.po |2 +-
 po/ka.po |2 +-
 po/kn.po |2 +-
 po/ko.po |2 +-
 po/ku.po |2 +-
 po/lo.po |2 +-
 po/lt.po |2 +-
 po/lv.po |2 +-
 po/mk.po |2 +-
 po/ml.po |2 +-
 po/mr.po |2 +-
 po/ms.po |2 +-
 po/my.po |2 +-
 po/nb.po |2 +-
 po/nl.po |2 +-
 po/nn.po |2 +-
 po/nso.po|2 +-
 po/or.po |2 +-
 po/pa.po |2 +-
 po/pl.po |2 +-
 po/pt.po |2 +-
 po/pt_BR.po  |2 +-
 po/ro.po |2 +-
 po/ru.po |2 +-
 po/si.po |2 +-
 po/sk.po |2 +-
 po/sl.po |2 +-
 po/sq.po |2 +-
 po/sr.po |2 +-
 po/s...@latin.po   |2 +-
 po/sv.po |2 +-
 po/ta.po |2 +-
 po/te.po |2 +-
 po/th.po |2 +-
 po/tr.po |2 +-
 po/uk.po |2 +-
 po/ur.po |2 +-
 po/vi.po |2 +-
 po/zh_CN.po  |2 +-
 po/zh_TW.po  |2 +-
 po/zu.po |2 +-
 src/qemu/qemu_monitor_text.c |2 +-
 74 files changed, 74 insertions(+), 74 deletions(-)

diff --git a/po/af.po b/po/af.po
index c64deda..c4711be 100644
--- a/po/af.po
+++ b/po/af.po
@@ -4957,7 +4957,7 @@ msgstr failed to read configuration file %s
 
 #: src/qemu/qemu_monitor_text.c:1828
 #, fuzzy, c-format
-msgid failed to remove host metnwork in qemu with '%s'
+msgid failed to remove host network in qemu with '%s'
 msgstr Failed to create domain from %s
 
 #: src/remote/remote_driver.c:328
diff --git a/po/am.po b/po/am.po
index c64deda..c4711be 100644
--- a/po/am.po
+++ b/po/am.po
@@ -4957,7 +4957,7 @@ msgstr failed to read configuration file %s
 
 #: src/qemu/qemu_monitor_text.c:1828
 #, fuzzy, c-format
-msgid failed to remove host metnwork in qemu with '%s'
+msgid failed to remove host network in qemu with '%s'
 msgstr Failed to create domain from %s
 
 #: src/remote/remote_driver.c:328
diff --git a/po/ar.po b/po/ar.po
index c64deda..c4711be 100644
--- a/po/ar.po
+++ b/po/ar.po
@@ -4957,7 +4957,7 @@ msgstr failed to read configuration file %s
 
 #: src/qemu/qemu_monitor_text.c:1828
 #, fuzzy, c-format
-msgid failed to remove host metnwork in qemu with '%s'
+msgid failed to remove host network in qemu with '%s'
 msgstr Failed to create domain from %s
 
 #: src/remote/remote_driver.c:328
diff --git a/po/as.po b/po/as.po
index b84d53b..3598e5b 100644
--- a/po/as.po
+++ b/po/as.po
@@ -5085,7 +5085,7 @@ msgstr %s বিনেস নথিপত্ৰ 
পঢ়োঁতে বিফল
 # c-format
 #: src/qemu/qemu_monitor_text.c:1828
 #, fuzzy, c-format
-msgid failed to remove host metnwork in qemu with '%s'
+msgid failed to remove host network in qemu with '%s'
 msgstr '%s' সহযোগে নেটওয়ার্কের 
ব্যাক-এন্ড মুছে ফেলতে ব্যর্থ\n
 
 #: src/remote/remote_driver.c:328
diff --git a/po/be.po b/po/be.po
index c64deda..c4711be 100644
--- a/po/be.po
+++ b/po/be.po
@@ -4957,7 +4957,7 @@ 

Re: [libvirt] [PATCH] Fix typo in error message

2009-11-17 Thread Matthew Booth

On 17/11/09 11:19, Daniel Veillard wrote:

On Tue, Nov 17, 2009 at 11:04:40AM +, Matthew Booth wrote:

* src/qemu/qemu_monitor_text.c: Fix typo
* po/*.po: Update typo in translations


   Please keep the po separate from patches :-)


Sure. Do you want a separate patch from me, or did you split it?

Matt
--
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

M:   +44 (0)7977 267231
GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 1/2] Fix guestfwdTarget indentation in domain.rng

2009-11-13 Thread Matthew Booth
* docs/schemas/domain.rng: Fix up some 4 space indentation
---
 docs/schemas/domain.rng |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index b75f17e..1bf44fd 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -1052,11 +1052,11 @@
   /define
   define name=guestfwdTarget
 element name=target
-attribute name=type
-valueguestfwd/value
-/attribute
-attribute name=address/
-attribute name=port/
+  attribute name=type
+valueguestfwd/value
+  /attribute
+  attribute name=address/
+  attribute name=port/
 /element
   /define
   define name=channel
-- 
1.6.2.5

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 2/2] guestfwd code tidy up

2009-11-13 Thread Matthew Booth
This patch removes qemudBuildCommandLineChrDevTargetStr and inlines its single
use. It was intended to be generic, but on reflection this can't work. Instead
it just makes the code slightly harder to read.

* src/qemu/qemu_conf.c: Remove and inline qemudBuildCommandLineChrDevTargetStr
---
 src/qemu/qemu_conf.c |   32 
 1 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 62b42fe..c807688 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1495,29 +1495,6 @@ static void 
qemudBuildCommandLineChrDevChardevStr(virDomainChrDefPtr dev,
 }
 }
 
-static int qemudBuildCommandLineChrDevTargetStr(virDomainChrDefPtr dev,
-const char *const id,
-virBufferPtr buf)
-{
-int ret = 0;
-const char *addr = NULL;
-
-int port;
-switch (dev-targetType) {
-case VIR_DOMAIN_CHR_TARGET_TYPE_GUESTFWD:
-addr = virSocketFormatAddr(dev-target.addr);
-port = virSocketGetPort(dev-target.addr);
-
-virBufferVSprintf(buf, user,guestfwd=tcp:%s:%i-chardev:%s,
-  addr, port, id);
-
-VIR_FREE(addr);
-break;
-}
-
-return ret;
-}
-
 static void qemudBuildCommandLineChrDevStr(virDomainChrDefPtr dev,
virBufferPtr buf)
 {
@@ -2205,7 +2182,14 @@ int qemudBuildCommandLine(virConnectPtr conn,
 ADD_ARG_LIT(-chardev);
 ADD_ARG(virBufferContentAndReset(buf));
 
-qemudBuildCommandLineChrDevTargetStr(channel, id, buf);
+const char *addr = virSocketFormatAddr(channel-target.addr);
+int port = virSocketGetPort(channel-target.addr);
+
+virBufferVSprintf(buf, user,guestfwd=tcp:%s:%i-chardev:%s,
+  addr, port, id);
+
+VIR_FREE(addr);
+
 if (virBufferError(buf))
 goto error;
 
-- 
1.6.2.5

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


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

2009-11-13 Thread Matthew Booth
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   |  102 +---
 .../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, 440 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 c807688..4f4b3db 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1844,12 +1844,36 @@ 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) {
+char id[16];
+
+if (snprintf(id, sizeof(id), monitor%i, i)  sizeof(id))
+goto error;
 
-ADD_ARG_LIT(-monitor);
-ADD_ARG(virBufferContentAndReset(buf));
+qemudBuildCommandLineChrDevChardevStr(monitor_chr, 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(-monitor);
+ADD_ARG(virBufferContentAndReset(buf));
+}
+
+else {
+qemudBuildCommandLineChrDevStr(monitor_chr, buf);
+

[libvirt] Rebased -vmchannel support

2009-11-09 Thread Matthew Booth
Updated patches are rebased on top of merged channel support. They additionally
move some definitions around to hopefully reduce the chances of future merge
conflicts.

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 1/2] Detect availability of legacy QEMU -vmchannel command line option

2009-11-09 Thread Matthew Booth
* src/qemu/qemu_conf.[ch]: Detect -vmchannel command line option
---
 src/qemu/qemu_conf.c |2 ++
 src/qemu/qemu_conf.h |1 +
 2 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index e1e24c3..fa54974 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -897,6 +897,8 @@ static unsigned int qemudComputeCmdFlags(const char *help,
 flags |= QEMUD_CMD_FLAG_MEM_PATH;
 if (strstr(help, -chardev))
 flags |= QEMUD_CMD_FLAG_CHARDEV;
+if (strstr(help, -vmchannel))
+flags |= QEMUD_CMD_FLAG_VMCHANNEL;
 
 if (version = 9000)
 flags |= QEMUD_CMD_FLAG_VNC_COLON;
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 5d433d3..54095b5 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -44,6 +44,7 @@
 
 /* Internal flags to keep track of qemu command line capabilities */
 enum qemud_cmd_flags {
+QEMUD_CMD_FLAG_VMCHANNEL = (1  31), /* Is the legacy -vmchannel arg 
available */
 QEMUD_CMD_FLAG_KQEMU  = (1  0), /* Whether KQEMU is compiled in 
*/
 QEMUD_CMD_FLAG_VNC_COLON  = (1  1), /* Does the VNC take just port, 
or address + display */
 QEMUD_CMD_FLAG_NO_REBOOT  = (1  2), /* Is the -no-reboot flag 
available */
-- 
1.6.2.5

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 2/2] Add channel support for legacy QEMU's -vmchannel CLI option

2009-11-09 Thread Matthew Booth
This patch allows the following to be specified in a QEmu domain:

channel type='unix'
  source mode='bind' path='/tmp/vmchannel'/
  target type='vmchannel' deviceid='0200'/
/channel

* docs/schemas/domain.rng src/conf/domain_conf.[ch]: extend the domain schema
  and parsing/serialization for the new construct

QEmu support adds the following on the qemu command line:

-vmchannel di:0200,unix:/tmp/vmchannel,server,nowait

* src/qemu/qemu_conf.c: Add -vmchannel argument output
* tests/qemuxml2(argv|xml)test.c: Add test for vmchannel channel syntax
---
 docs/schemas/domain.rng|   13 -
 src/conf/domain_conf.c |   30 +++-
 src/conf/domain_conf.h |2 +
 src/qemu/qemu_conf.c   |   18 
 .../qemuxml2argv-channel-vmchannel.args|1 +
 .../qemuxml2argv-channel-vmchannel.xml |   26 +
 tests/qemuxml2argvtest.c   |1 +
 tests/qemuxml2xmltest.c|2 +
 8 files changed, 91 insertions(+), 2 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-vmchannel.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-vmchannel.xml

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index b75f17e..39a19ae 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -1059,12 +1059,23 @@
 attribute name=port/
 /element
   /define
+  define name=vmchannelTarget
+element name=target
+attribute name=type
+valuevmchannel/value
+/attribute
+attribute name=deviceid/
+/element
+  /define
   define name=channel
 element name=channel
   ref name=qemucdevSrcType/
   interleave
 ref name=qemucdevSrcDef/
-ref name=guestfwdTarget/
+choice
+  ref name=guestfwdTarget/
+  ref name=vmchannelTarget/
+/choice
   /interleave
 /element
   /define
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 918a5d7..c02b959 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -130,6 +130,7 @@ VIR_ENUM_IMPL(virDomainNet, VIR_DOMAIN_NET_TYPE_LAST,
 
 VIR_ENUM_IMPL(virDomainChrTarget, VIR_DOMAIN_CHR_TARGET_TYPE_LAST,
   null,
+  vmchannel,
   monitor,
   parallel,
   serial,
@@ -1349,6 +1350,7 @@ virDomainChrDefParseXML(virConnectPtr conn,
 const char *targetType = NULL;
 const char *addrStr = NULL;
 const char *portStr = NULL;
+const char *deviceidStr = NULL;
 virDomainChrDefPtr def;
 
 if (VIR_ALLOC(def)  0) {
@@ -1504,6 +1506,26 @@ virDomainChrDefParseXML(virConnectPtr conn,
 virSocketSetPort(def-target.addr, port);
 break;
 
+case VIR_DOMAIN_CHR_TARGET_TYPE_VMCHANNEL:
+deviceidStr = virXMLPropString(cur, deviceid);
+
+if (deviceidStr == NULL) {
+virDomainReportError(conn, VIR_ERR_INVALID_DOMAIN,
+ _(vmchannel channel does not 
+   define a device id));
+goto error;
+}
+
+unsigned int deviceid;
+if (virStrToLong_ui(deviceidStr, NULL, 16, deviceid)  0) 
{
+virDomainReportError(conn, VIR_ERR_INVALID_DOMAIN,
+ _(Invalid device id: %s),
+ deviceidStr);
+goto error;
+}
+def-target.deviceid = deviceid;
+break;
+
 default:
 virDomainReportError(conn, VIR_ERR_XML_ERROR,
  _(unexpected target type type %u),
@@ -1514,7 +1536,6 @@ virDomainChrDefParseXML(virConnectPtr conn,
 cur = cur-next;
 }
 
-
 switch (def-type) {
 case VIR_DOMAIN_CHR_TYPE_NULL:
 /* Nada */
@@ -1641,6 +1662,7 @@ cleanup:
 VIR_FREE(targetType);
 VIR_FREE(addrStr);
 VIR_FREE(portStr);
+VIR_FREE(deviceidStr);
 
 return def;
 
@@ -4125,6 +4147,7 @@ virDomainChrDefFormat(virConnectPtr conn,
 switch (def-targetType) {
 /* channel types are in a common channel element */
 case VIR_DOMAIN_CHR_TARGET_TYPE_GUESTFWD:
+case VIR_DOMAIN_CHR_TARGET_TYPE_VMCHANNEL:
 elementName = channel;
 break;
 
@@ -4237,6 +4260,11 @@ virDomainChrDefFormat(virConnectPtr conn,
   addr, port);
 break;
 
+case VIR_DOMAIN_CHR_TARGET_TYPE_VMCHANNEL:
+virBufferVSprintf(buf,   target type='vmchannel' 
deviceid='%.4X'/\n,
+  def-target.deviceid);
+break;
+
 case 

[libvirt] [PATCH] network utilities: Properly convert port numbers to/from network byte order

2009-11-04 Thread Matthew Booth
* src/util/network.c: Add htons and ntohs in virSocket(Get|Set)Port
---
 src/util/network.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/util/network.c b/src/util/network.c
index d67340a..56426e7 100644
--- a/src/util/network.c
+++ b/src/util/network.c
@@ -173,6 +173,8 @@ virSocketSetPort(virSocketAddrPtr addr, int port) {
 if (addr == NULL)
 return -1;
 
+port = htons(port);
+
 if(addr-stor.ss_family == AF_INET) {
 addr-inet4.sin_port = port;
 }
@@ -201,11 +203,11 @@ virSocketGetPort(virSocketAddrPtr addr) {
 return -1;
 
 if(addr-stor.ss_family == AF_INET) {
-return addr-inet4.sin_port;
+return ntohs(addr-inet4.sin_port);
 }
 
 else if(addr-stor.ss_family == AF_INET6) {
-return addr-inet6.sin6_port;
+return ntohs(addr-inet6.sin6_port);
 }
 
 return -1;
-- 
1.6.2.5

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] network utilities: Allocate space for terminating NUL in virSocketFormatAddr

2009-11-04 Thread Matthew Booth
* src/util/network.c: Allocate an additional byte for virSocketFormatAddr's
  return buffer
---
 src/util/network.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/util/network.c b/src/util/network.c
index 56426e7..f6588c7 100644
--- a/src/util/network.c
+++ b/src/util/network.c
@@ -135,12 +135,12 @@ virSocketFormatAddr(virSocketAddrPtr addr) {
 return NULL;
 
 if (addr-stor.ss_family == AF_INET) {
-outlen = INET_ADDRSTRLEN;
+outlen = INET_ADDRSTRLEN + 1;
 inaddr = addr-inet4.sin_addr;
 }
 
 else if (addr-stor.ss_family == AF_INET6) {
-outlen = INET6_ADDRSTRLEN;
+outlen = INET6_ADDRSTRLEN + 1;
 inaddr = addr-inet6.sin6_addr;
 }
 
-- 
1.6.2.5

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] network utilities: Allocate space for terminating NUL in virSocketFormatAddr

2009-11-04 Thread Matthew Booth

On 04/11/09 11:06, Richard W.M. Jones wrote:

Are you sure about this?  According to the man page for inet_ntop the
INET*_ADDRSTRLEN macro should be long enough already:

AF_INET
   src points to a struct in_addr (in network byte order) which  is
   converted  to an IPv4 network address in the dotted-decimal for-
   mat,  ddd.ddd.ddd.ddd.   The  buffer  dst  must  be  at  least
   INET_ADDRSTRLEN bytes long.

AF_INET6
   src points to a struct in6_addr (in network byte order) which is
   converted to a representation of this address in the most appro-
   priate IPv6 network address format for this address.  The buffer
   dst must be at least INET6_ADDRSTRLEN bytes long.


No, I wasn't sure :) However, reading this and realising I miscalculated 
the maximum size of an IPv4 address[1], I'll withdraw this patch.


Thanks,

Matt

[1] INET_ADDRSTRLEN == 16. I forgot there's only 3 dots, so I didn't 
think it was leaving space.

--
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

M:   +44 (0)7977 267231
GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 2/2] Add support for legacy QEMU's -vmchannel command line option

2009-11-04 Thread Matthew Booth

On 04/11/09 11:30, Richard W.M. Jones wrote:

On Tue, Nov 03, 2009 at 04:11:48PM +, Matthew Booth wrote:

This patch allows the following to be specified in a qemu domain:


The patch looks sensible.  What would be the problem with merging this
functionality into libvirt?  It seems it could be useful for someone
supporting a RHEL 5 hypervisor.



They'd have to be running new libvirt on RHEL 5, which doesn't sound 
like a likely combination. If the -vmchannel command line option is 
likely to live on beyond RHEL 5, though, I guess it might make sense to 
merge this.


Matt
--
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

M:   +44 (0)7977 267231
GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 3/4] chardev: Add function to output -chardev options

2009-11-04 Thread Matthew Booth
Agree virBuffer is nicer here, although it's not used anywhere else in
qemu_conf.c. Here's an updated patch which uses a virBuffer instead.

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] chardev: Add function to output -chardev options

2009-11-04 Thread Matthew Booth
Note that, on its own, this patch will generate a warning about an unused static
function.
---
 src/qemu/qemu_conf.c |   68 ++
 1 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 2981b51..a9f6885 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1411,6 +1411,74 @@ qemuBuildHostNetStr(virConnectPtr conn,
 return 0;
 }
 
+/* This function outputs a -chardev command line option which describes only 
the
+ * host side of the character device */
+static void qemudBuildCommandLineChrDevChardevStr(virDomainChrDefPtr dev,
+  const char *const id,
+  virBufferPtr buf)
+{
+bool telnet;
+switch(dev-type) {
+case VIR_DOMAIN_CHR_TYPE_NULL:
+virBufferVSprintf(buf, null,id=%s, id);
+break;
+
+case VIR_DOMAIN_CHR_TYPE_VC:
+virBufferVSprintf(buf, vc,id=%s, id);
+break;
+
+case VIR_DOMAIN_CHR_TYPE_PTY:
+virBufferVSprintf(buf, pty,id=%s, id);
+break;
+
+case VIR_DOMAIN_CHR_TYPE_DEV:
+virBufferVSprintf(buf, tty,id=%s,path=%s, id, dev-data.file.path);
+break;
+
+case VIR_DOMAIN_CHR_TYPE_FILE:
+virBufferVSprintf(buf, file,id=%s,path=%s, id, dev-data.file.path);
+break;
+
+case VIR_DOMAIN_CHR_TYPE_PIPE:
+virBufferVSprintf(buf, pipe,id=%s,path=%s, id, dev-data.file.path);
+break;
+
+case VIR_DOMAIN_CHR_TYPE_STDIO:
+virBufferVSprintf(buf, stdio,id=%s, id);
+break;
+
+case VIR_DOMAIN_CHR_TYPE_UDP:
+virBufferVSprintf(buf,
+  
udp,id=%s,host=%s,port=%s,localaddr=%s,localport=%s,
+  id,
+  dev-data.udp.connectHost,
+  dev-data.udp.connectService,
+  dev-data.udp.bindHost,
+  dev-data.udp.bindService);
+break;
+
+case VIR_DOMAIN_CHR_TYPE_TCP:
+telnet = dev-data.tcp.protocol == VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET;
+virBufferVSprintf(buf,
+  socket,id=%s,host=%s,port=%s%s%s,
+  id,
+  dev-data.tcp.host,
+  dev-data.tcp.service,
+  telnet ? ,telnet : ,
+  dev-data.tcp.listen ? ,server,nowait : );
+break;
+
+case VIR_DOMAIN_CHR_TYPE_UNIX:
+virBufferVSprintf(buf,
+  socket,id=%s,path=%s%s,
+  id,
+  dev-data.nix.path,
+  dev-data.nix.listen ? ,server,nowait : );
+break;
+}
+}
+
+/* This function outputs an all-in-one character device command line option */
 static int qemudBuildCommandLineChrDevStr(virDomainChrDefPtr dev,
   char *buf,
   int buflen)
-- 
1.6.2.5

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] Guestfwd support (round 3)

2009-11-04 Thread Matthew Booth
This is substantially the same as the last set. I don't think I changed patches
1 and 2 at all.

Patch 3 is updated to use a virBuffer as Rich Jones recommended.

Patch 4 is updated slightly for the above change, and there are a couple of
other trivial tidy ups in there.

Patch 5 is new. QEMU's guestfwd only supports IPv4 addresses, so we check for
that.

Rich Jones also noted that guestfwd is specific to QEMU. If there's a good
chance this same syntax might do something simililar in a different driver, I
agree that changing the name would be a good idea. However, I'm not familiar
enough with other hypervisors to be able to make a call on this. If nothing else
does anything similar, I'd keep the QEMU name for clarity.

Matt

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 1/5] character device: Allow character devices to have different target types

2009-11-04 Thread Matthew Booth
Currently a character device's target (it's interface in the guest) has only a
single property: port. This patch is in preparation for adding targets which
require other properties.

Target properties are moved into a union in virDomainChrDef, and a targetType
field is added to identify which union member should be used. All current code
which touches a virDomainChrDef is updated both to use the new union field,
and to populate targetType if necessary.
---
 src/conf/domain_conf.c  |   66 +-
 src/conf/domain_conf.h  |   18 +++-
 src/esx/esx_vmx.c   |   56 +--
 src/qemu/qemu_conf.c|6 +++-
 src/qemu/qemu_driver.c  |2 +
 src/uml/uml_conf.c  |   12 
 src/uml/uml_driver.c|2 +-
 src/vbox/vbox_tmpl.c|   22 
 src/xen/xend_internal.c |3 ++
 src/xen/xm_internal.c   |3 ++
 10 files changed, 129 insertions(+), 61 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7dd3ce7..fc70cfd 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -127,6 +127,13 @@ VIR_ENUM_IMPL(virDomainNet, VIR_DOMAIN_NET_TYPE_LAST,
   bridge,
   internal)
 
+VIR_ENUM_IMPL(virDomainChrTarget, VIR_DOMAIN_CHR_TARGET_TYPE_LAST,
+  null,
+  monitor,
+  parallel,
+  serial,
+  console)
+
 VIR_ENUM_IMPL(virDomainChr, VIR_DOMAIN_CHR_TYPE_LAST,
   null,
   vc,
@@ -1325,6 +1332,7 @@ virDomainChrDefParseXML(virConnectPtr conn,
 char *path = NULL;
 char *mode = NULL;
 char *protocol = NULL;
+const char *targetType = NULL;
 virDomainChrDefPtr def;
 
 if (VIR_ALLOC(def)  0) {
@@ -1338,6 +1346,21 @@ virDomainChrDefParseXML(virConnectPtr conn,
 else if ((def-type = virDomainChrTypeFromString(type))  0)
 def-type = VIR_DOMAIN_CHR_TYPE_NULL;
 
+targetType = (const char *) node-name;
+if (targetType == NULL) {
+/* Shouldn't be possible */
+virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ node-name is NULL at %s:%i,
+ __FILE__, __LINE__);
+return NULL;
+}
+if ((def-targetType = virDomainChrTargetTypeFromString(targetType))  0) {
+virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _(unknown target type for character device: %s),
+ targetType);
+def-targetType = VIR_DOMAIN_CHR_TARGET_TYPE_NULL;
+}
+
 cur = node-children;
 while (cur != NULL) {
 if (cur-type == XML_ELEMENT_NODE) {
@@ -2931,7 +2954,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr 
conn,
 if (!chr)
 goto error;
 
-chr-dstPort = i;
+chr-target.port = i;
 def-parallels[def-nparallels++] = chr;
 }
 VIR_FREE(nodes);
@@ -2951,7 +2974,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr 
conn,
 if (!chr)
 goto error;
 
-chr-dstPort = i;
+chr-target.port = i;
 def-serials[def-nserials++] = chr;
 }
 VIR_FREE(nodes);
@@ -2963,7 +2986,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr 
conn,
 if (!chr)
 goto error;
 
-chr-dstPort = 0;
+chr-target.port = 0;
 /*
  * For HVM console actually created a serial device
  * while for non-HVM it was a parvirt console
@@ -3965,10 +3988,12 @@ static int
 virDomainChrDefFormat(virConnectPtr conn,
   virBufferPtr buf,
   virDomainChrDefPtr def,
-  const char *name,
   int flags)
 {
 const char *type = virDomainChrTypeToString(def-type);
+const char *targetName = virDomainChrTargetTypeToString(def-targetType);
+
+const char *elementName = targetName; /* Currently always the same */
 
 if (!type) {
 virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
@@ -3978,8 +4003,8 @@ virDomainChrDefFormat(virConnectPtr conn,
 
 /* Compat with legacy  console tty='/dev/pts/5'/ syntax */
 virBufferVSprintf(buf, %s type='%s',
-  name, type);
-if (STREQ(name, console) 
+  elementName, type);
+if (def-targetType == VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE 
 def-type == VIR_DOMAIN_CHR_TYPE_PTY 
 !(flags  VIR_DOMAIN_XML_INACTIVE) 
 def-data.file.path) {
@@ -4054,11 +4079,23 @@ virDomainChrDefFormat(virConnectPtr conn,
 break;
 }
 
-virBufferVSprintf(buf,   target port='%d'/\n,
-  def-dstPort);
+switch (def-targetType) {
+case VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL:
+case VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL:
+case VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE:
+virBufferVSprintf(buf,   target port='%d'/\n,
+  def-target.port);

[libvirt] [PATCH 2/5] Detect availability of QEMU -chardev command line option

2009-11-04 Thread Matthew Booth
---
 src/qemu/qemu_conf.c |2 ++
 src/qemu/qemu_conf.h |1 +
 2 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 19b2d36..2981b51 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -894,6 +894,8 @@ static unsigned int qemudComputeCmdFlags(const char *help,
 flags |= QEMUD_CMD_FLAG_PCIDEVICE;
 if (strstr(help, -mem-path))
 flags |= QEMUD_CMD_FLAG_MEM_PATH;
+if (strstr(help, -chardev))
+flags |= QEMUD_CMD_FLAG_CHARDEV;
 
 if (version = 9000)
 flags |= QEMUD_CMD_FLAG_VNC_COLON;
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 53835cf..0f82c68 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -73,6 +73,7 @@ enum qemud_cmd_flags {
 QEMUD_CMD_FLAG_DRIVE_SERIAL  = (1  19), /* -driver serial=  available */
 QEMUD_CMD_FLAG_XEN_DOMID = (1  20), /* -xen-domid (new style xen 
integration) */
 QEMUD_CMD_FLAG_MIGRATE_QEMU_UNIX = (1  21), /* Does qemu support unix 
domain sockets for migration? */
+QEMUD_CMD_FLAG_CHARDEV   = (1  22), /* Is the new -chardev arg 
available */
 };
 
 /* Main driver state */
-- 
1.6.2.5

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 3/5] chardev: Add function to output -chardev options

2009-11-04 Thread Matthew Booth
Note that, on its own, this patch will generate a warning about an unused static
function.
---
 src/qemu/qemu_conf.c |   68 ++
 1 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 2981b51..a9f6885 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1411,6 +1411,74 @@ qemuBuildHostNetStr(virConnectPtr conn,
 return 0;
 }
 
+/* This function outputs a -chardev command line option which describes only 
the
+ * host side of the character device */
+static void qemudBuildCommandLineChrDevChardevStr(virDomainChrDefPtr dev,
+  const char *const id,
+  virBufferPtr buf)
+{
+bool telnet;
+switch(dev-type) {
+case VIR_DOMAIN_CHR_TYPE_NULL:
+virBufferVSprintf(buf, null,id=%s, id);
+break;
+
+case VIR_DOMAIN_CHR_TYPE_VC:
+virBufferVSprintf(buf, vc,id=%s, id);
+break;
+
+case VIR_DOMAIN_CHR_TYPE_PTY:
+virBufferVSprintf(buf, pty,id=%s, id);
+break;
+
+case VIR_DOMAIN_CHR_TYPE_DEV:
+virBufferVSprintf(buf, tty,id=%s,path=%s, id, dev-data.file.path);
+break;
+
+case VIR_DOMAIN_CHR_TYPE_FILE:
+virBufferVSprintf(buf, file,id=%s,path=%s, id, dev-data.file.path);
+break;
+
+case VIR_DOMAIN_CHR_TYPE_PIPE:
+virBufferVSprintf(buf, pipe,id=%s,path=%s, id, dev-data.file.path);
+break;
+
+case VIR_DOMAIN_CHR_TYPE_STDIO:
+virBufferVSprintf(buf, stdio,id=%s, id);
+break;
+
+case VIR_DOMAIN_CHR_TYPE_UDP:
+virBufferVSprintf(buf,
+  
udp,id=%s,host=%s,port=%s,localaddr=%s,localport=%s,
+  id,
+  dev-data.udp.connectHost,
+  dev-data.udp.connectService,
+  dev-data.udp.bindHost,
+  dev-data.udp.bindService);
+break;
+
+case VIR_DOMAIN_CHR_TYPE_TCP:
+telnet = dev-data.tcp.protocol == VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET;
+virBufferVSprintf(buf,
+  socket,id=%s,host=%s,port=%s%s%s,
+  id,
+  dev-data.tcp.host,
+  dev-data.tcp.service,
+  telnet ? ,telnet : ,
+  dev-data.tcp.listen ? ,server,nowait : );
+break;
+
+case VIR_DOMAIN_CHR_TYPE_UNIX:
+virBufferVSprintf(buf,
+  socket,id=%s,path=%s%s,
+  id,
+  dev-data.nix.path,
+  dev-data.nix.listen ? ,server,nowait : );
+break;
+}
+}
+
+/* This function outputs an all-in-one character device command line option */
 static int qemudBuildCommandLineChrDevStr(virDomainChrDefPtr dev,
   char *buf,
   int buflen)
-- 
1.6.2.5

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 5/5] guestfwd: Ensure guestfwd address is IPv4

2009-11-04 Thread Matthew Booth
* src/conf/domain_conf.c: Throw an error if guestfwd address isn't IPv4
---
 src/conf/domain_conf.c |7 +++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 94bce1e..ec2a1bc 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1482,6 +1482,13 @@ virDomainChrDefParseXML(virConnectPtr conn,
 goto error;
 }
 
+if(def-target.addr-stor.ss_family != AF_INET) {
+virDomainReportError(conn, VIR_ERR_NO_SUPPORT, %s,
+ _(guestfwd channel only supports 

+   IPv4 addresses));
+goto error;
+}
+
 if(portStr == NULL) {
 virDomainReportError(conn, VIR_ERR_INVALID_DOMAIN, 
%s,
  _(guestfwd channel does 
-- 
1.6.2.5

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 4/5] Add support for qemu's guestfwd

2009-11-04 Thread Matthew Booth
This patch allows the following to be specified in a qemu domain:

channel type='pipe'
  source path='/tmp/guestfwd'/
  target type='guestfwd' address='10.0.2.1' port='4600'/
/channel

This will output the following on the qemu command line:

-chardev pipe,id=channel0,path=/tmp/guestfwd \
-net user,guestfwd=tcp:10.0.2.1:4600-chardev:channel0

* docs/schemas/domain.rng: Add channel and guestfwd elements
* proxy/Makefile.am: add network.c as dep of domain_conf.c
* src/conf/domain_conf.[ch]: Add xml parsing/formatting for channel and guestfwd
* src/qemu/qemu_conf.c: Add argument output for guestfwd
* tests/qemuxml2(argv|xml)test.c: Add test for guestfwd domain syntax
---
 docs/schemas/domain.rng|   89 ++
 proxy/Makefile.am  |1 +
 src/conf/domain_conf.c |  189 ++--
 src/conf/domain_conf.h |6 +
 src/qemu/qemu_conf.c   |   64 +++
 .../qemuxml2argv-channel-guestfwd.args |1 +
 .../qemuxml2argv-channel-guestfwd.xml  |   26 +++
 tests/qemuxml2argvtest.c   |4 +-
 tests/qemuxml2xmltest.c|1 +
 9 files changed, 332 insertions(+), 49 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-guestfwd.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-guestfwd.xml

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index 0a6ab61..b75f17e 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -930,6 +930,19 @@
   definition doesn't fully specify the constraints on this node.
 --
   define name=qemucdev
+ref name=qemucdevSrcType/
+interleave
+  ref name=qemucdevSrcDef/
+  optional
+element name=target
+  optional
+attribute name=port/
+  /optional
+/element
+  /optional
+/interleave
+  /define
+  define name=qemucdevSrcType
 attribute name=type
   choice
 valuedev/value
@@ -944,43 +957,36 @@
 valuepty/value
   /choice
 /attribute
-interleave
-  optional
-oneOrMore
-  element name=source
-optional
-  attribute name=mode/
-/optional
-optional
-  attribute name=path/
-/optional
-optional
-  attribute name=host/
-/optional
-optional
-  attribute name=service/
-/optional
-optional
-  attribute name=wiremode/
-/optional
-  /element
-/oneOrMore
-  /optional
-  optional
-element name=protocol
+  /define
+  define name=qemucdevSrcDef
+optional
+  oneOrMore
+element name=source
   optional
-attribute name=type/
+attribute name=mode/
   /optional
-/element
-  /optional
-  optional
-element name=target
   optional
-attribute name=port/
+attribute name=path/
+  /optional
+  optional
+attribute name=host/
+  /optional
+  optional
+attribute name=service/
+  /optional
+  optional
+attribute name=wiremode/
   /optional
 /element
-  /optional
-/interleave
+  /oneOrMore
+/optional
+optional
+  element name=protocol
+optional
+  attribute name=type/
+/optional
+  /element
+/optional
   /define
   !--
   The description for a console
@@ -1044,6 +1050,24 @@
   ref name=qemucdev/
 /element
   /define
+  define name=guestfwdTarget
+element name=target
+attribute name=type
+valueguestfwd/value
+/attribute
+attribute name=address/
+attribute name=port/
+/element
+  /define
+  define name=channel
+element name=channel
+  ref name=qemucdevSrcType/
+  interleave
+ref name=qemucdevSrcDef/
+ref name=guestfwdTarget/
+  /interleave
+/element
+  /define
   define name=input
 element name=input
   attribute name=type
@@ -1158,6 +1182,7 @@
 ref name=console/
 ref name=parallel/
 ref name=serial/
+ref name=channel/
   /choice
 /zeroOrMore
 optional
diff --git a/proxy/Makefile.am b/proxy/Makefile.am
index 3e0050b..42f6a81 100644
--- a/proxy/Makefile.am
+++ b/proxy/Makefile.am
@@ -17,6 +17,7 @@ libvirt_proxy_SOURCES = libvirt_proxy.c \
 @top_srcdir@/src/util/buf.c \
@top_srcdir@/src/util/logging.c \
 @top_srcdir@/src/util/memory.c \
+@top_srcdir@/src/util/network.c \
@top_srcdir@/src/util/threads.c  \
 @top_srcdir@/src/util/util.c \
@top_srcdir@/src/util/uuid.c \
diff --git 

[libvirt] [PATCH] Use virBuffer when constructing QEMU character device command line

2009-11-04 Thread Matthew Booth
This patch updates qemudBuildCommandLineChrDevStr to use a virBuffer instead of
a char[]. This is slightly tidier, and it makes it cleaner to (ap|pre)pend the
output in other command lines.

* src/qemu/qemu_conf.c: Update qemudBuildCommandLineChrDevStr to use a virBuffer
---
 src/qemu/qemu_conf.c |   97 +++--
 1 files changed, 46 insertions(+), 51 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 40613dd..052ae98 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1409,83 +1409,66 @@ qemuBuildHostNetStr(virConnectPtr conn,
 return 0;
 }
 
-static int qemudBuildCommandLineChrDevStr(virDomainChrDefPtr dev,
-  char *buf,
-  int buflen)
+static void qemudBuildCommandLineChrDevStr(virDomainChrDefPtr dev,
+   virBufferPtr buf)
 {
 switch (dev-type) {
 case VIR_DOMAIN_CHR_TYPE_NULL:
-if (virStrcpy(buf, null, buflen) == NULL)
-return -1;
+virBufferAddLit(buf, null);
 break;
 
 case VIR_DOMAIN_CHR_TYPE_VC:
-if (virStrcpy(buf, vc, buflen) == NULL)
-return -1;
+virBufferAddLit(buf, vc);
 break;
 
 case VIR_DOMAIN_CHR_TYPE_PTY:
-if (virStrcpy(buf, pty, buflen) == NULL)
-return -1;
+virBufferAddLit(buf, pty);
 break;
 
 case VIR_DOMAIN_CHR_TYPE_DEV:
-if (snprintf(buf, buflen, %s,
- dev-data.file.path) = buflen)
-return -1;
+virBufferStrcat(buf, dev-data.file.path, NULL);
 break;
 
 case VIR_DOMAIN_CHR_TYPE_FILE:
-if (snprintf(buf, buflen, file:%s,
- dev-data.file.path) = buflen)
-return -1;
+virBufferVSprintf(buf, file:%s, dev-data.file.path);
 break;
 
 case VIR_DOMAIN_CHR_TYPE_PIPE:
-if (snprintf(buf, buflen, pipe:%s,
- dev-data.file.path) = buflen)
-return -1;
+virBufferVSprintf(buf, pipe:%s, dev-data.file.path);
 break;
 
 case VIR_DOMAIN_CHR_TYPE_STDIO:
-if (virStrcpy(buf, stdio, buflen) == NULL)
-return -1;
+virBufferAddLit(buf, stdio);
 break;
 
 case VIR_DOMAIN_CHR_TYPE_UDP:
-if (snprintf(buf, buflen, udp:%s:%...@%s:%s,
- dev-data.udp.connectHost,
- dev-data.udp.connectService,
- dev-data.udp.bindHost,
- dev-data.udp.bindService) = buflen)
-return -1;
+virBufferVSprintf(buf, udp:%s:%...@%s:%s,
+  dev-data.udp.connectHost,
+  dev-data.udp.connectService,
+  dev-data.udp.bindHost,
+  dev-data.udp.bindService);
 break;
 
 case VIR_DOMAIN_CHR_TYPE_TCP:
 if (dev-data.tcp.protocol == VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET) {
-if (snprintf(buf, buflen, telnet:%s:%s%s,
- dev-data.tcp.host,
- dev-data.tcp.service,
- dev-data.tcp.listen ? ,server,nowait : ) = 
buflen)
-return -1;
+virBufferVSprintf(buf, telnet:%s:%s%s,
+  dev-data.tcp.host,
+  dev-data.tcp.service,
+  dev-data.tcp.listen ? ,server,nowait : );
 } else {
-if (snprintf(buf, buflen, tcp:%s:%s%s,
- dev-data.tcp.host,
- dev-data.tcp.service,
- dev-data.tcp.listen ? ,server,nowait : ) = 
buflen)
-return -1;
+virBufferVSprintf(buf, tcp:%s:%s%s,
+  dev-data.tcp.host,
+  dev-data.tcp.service,
+  dev-data.tcp.listen ? ,server,nowait : );
 }
 break;
 
 case VIR_DOMAIN_CHR_TYPE_UNIX:
-if (snprintf(buf, buflen, unix:%s%s,
- dev-data.nix.path,
- dev-data.nix.listen ? ,server,nowait : ) = buflen)
-return -1;
+virBufferVSprintf(buf, unix:%s%s,
+  dev-data.nix.path,
+  dev-data.nix.listen ? ,server,nowait : );
 break;
 }
-
-return 0;
 }
 
 #define QEMU_SERIAL_PARAM_ACCEPTED_CHARS \
@@ -1773,13 +1756,17 @@ int qemudBuildCommandLine(virConnectPtr conn,
 ADD_ARG_LIT(-nographic);
 
 if (monitor_chr) {
-char buf[4096];
+virBuffer buf = VIR_BUFFER_INITIALIZER;
 
-if (qemudBuildCommandLineChrDevStr(monitor_chr, buf, sizeof(buf))  0)
+qemudBuildCommandLineChrDevStr(monitor_chr, buf);
+const char *argStr = virBufferContentAndReset(buf);
+if (argStr == NULL)
 goto error;
 
 ADD_ARG_LIT(-monitor);
-   

[libvirt] Add support for qemu's guestfwd

2009-11-03 Thread Matthew Booth
This is an update of the patchset I posted yesterday. There have been a few
changes in the 4th patch, which actually adds guestfwd support:

Firstly, after discussion on IRC, it was agreed that 'vmchannel' is a poor name
for the collection of implementations of private host-guest channels, because
it is the name of a specific implementation. Consequently the name has been
changed to just 'channel'.

Secondly, I've fixed a bunch of things I noticed while adding actual vmchannel
support (patches to follow separately).

Lastly, I've changed the relax-ng a bit to check the precise set of attributes
for guestfwd. This change is also followed up in the vmchannel support.

The patch now supports the following domain XML:

channel type='pipe'
  source path='/tmp/guestfwd'/
  target type='guestfwd' address='10.0.2.1' port='4600'/
/channel

It will output the following on the qemu command line for this:

-chardev pipe,id=channel0,path=/tmp/guestfwd \
-net user,guestfwd=tcp:10.0.2.1:4600-chardev:channel0

Support for -chardev is as complete as the current character device support.

Because of the legacy vmchannel, there was also some confusion about whether
these patches are intended for merging. These patches aren't directly related
to vmchannel, and are targeted at merging.

Matt

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 1/4] character device: Allow character devices to have different target types

2009-11-03 Thread Matthew Booth
Currently a character device's target (it's interface in the guest) has only a
single property: port. This patch is in preparation for adding targets which
require other properties.

Target properties are moved into a union in virDomainChrDef, and a targetType
field is added to identify which union member should be used. All current code
which touches a virDomainChrDef is updated both to use the new union field,
and to populate targetType if necessary.
---
 src/conf/domain_conf.c  |   66 +-
 src/conf/domain_conf.h  |   18 +++-
 src/esx/esx_vmx.c   |   56 +--
 src/qemu/qemu_conf.c|6 +++-
 src/qemu/qemu_driver.c  |2 +
 src/uml/uml_conf.c  |   12 
 src/uml/uml_driver.c|2 +-
 src/vbox/vbox_tmpl.c|   22 
 src/xen/xend_internal.c |3 ++
 src/xen/xm_internal.c   |3 ++
 10 files changed, 129 insertions(+), 61 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a9c8573..e050453 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -127,6 +127,13 @@ VIR_ENUM_IMPL(virDomainNet, VIR_DOMAIN_NET_TYPE_LAST,
   bridge,
   internal)
 
+VIR_ENUM_IMPL(virDomainChrTarget, VIR_DOMAIN_CHR_TARGET_TYPE_LAST,
+  null,
+  monitor,
+  parallel,
+  serial,
+  console)
+
 VIR_ENUM_IMPL(virDomainChr, VIR_DOMAIN_CHR_TYPE_LAST,
   null,
   vc,
@@ -1325,6 +1332,7 @@ virDomainChrDefParseXML(virConnectPtr conn,
 char *path = NULL;
 char *mode = NULL;
 char *protocol = NULL;
+const char *targetType = NULL;
 virDomainChrDefPtr def;
 
 if (VIR_ALLOC(def)  0) {
@@ -1338,6 +1346,21 @@ virDomainChrDefParseXML(virConnectPtr conn,
 else if ((def-type = virDomainChrTypeFromString(type))  0)
 def-type = VIR_DOMAIN_CHR_TYPE_NULL;
 
+targetType = (const char *) node-name;
+if (targetType == NULL) {
+/* Shouldn't be possible */
+virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ node-name is NULL at %s:%i,
+ __FILE__, __LINE__);
+return NULL;
+}
+if ((def-targetType = virDomainChrTargetTypeFromString(targetType))  0) {
+virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _(unknown target type for character device: %s),
+ targetType);
+def-targetType = VIR_DOMAIN_CHR_TARGET_TYPE_NULL;
+}
+
 cur = node-children;
 while (cur != NULL) {
 if (cur-type == XML_ELEMENT_NODE) {
@@ -2931,7 +2954,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr 
conn,
 if (!chr)
 goto error;
 
-chr-dstPort = i;
+chr-target.port = i;
 def-parallels[def-nparallels++] = chr;
 }
 VIR_FREE(nodes);
@@ -2951,7 +2974,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr 
conn,
 if (!chr)
 goto error;
 
-chr-dstPort = i;
+chr-target.port = i;
 def-serials[def-nserials++] = chr;
 }
 VIR_FREE(nodes);
@@ -2963,7 +2986,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr 
conn,
 if (!chr)
 goto error;
 
-chr-dstPort = 0;
+chr-target.port = 0;
 /*
  * For HVM console actually created a serial device
  * while for non-HVM it was a parvirt console
@@ -3965,10 +3988,12 @@ static int
 virDomainChrDefFormat(virConnectPtr conn,
   virBufferPtr buf,
   virDomainChrDefPtr def,
-  const char *name,
   int flags)
 {
 const char *type = virDomainChrTypeToString(def-type);
+const char *targetName = virDomainChrTargetTypeToString(def-targetType);
+
+const char *elementName = targetName; /* Currently always the same */
 
 if (!type) {
 virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
@@ -3978,8 +4003,8 @@ virDomainChrDefFormat(virConnectPtr conn,
 
 /* Compat with legacy  console tty='/dev/pts/5'/ syntax */
 virBufferVSprintf(buf, %s type='%s',
-  name, type);
-if (STREQ(name, console) 
+  elementName, type);
+if (def-targetType == VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE 
 def-type == VIR_DOMAIN_CHR_TYPE_PTY 
 !(flags  VIR_DOMAIN_XML_INACTIVE) 
 def-data.file.path) {
@@ -4054,11 +4079,23 @@ virDomainChrDefFormat(virConnectPtr conn,
 break;
 }
 
-virBufferVSprintf(buf,   target port='%d'/\n,
-  def-dstPort);
+switch (def-targetType) {
+case VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL:
+case VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL:
+case VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE:
+virBufferVSprintf(buf,   target port='%d'/\n,
+  def-target.port);

[libvirt] [PATCH 2/4] Detect availability of QEMU -chardev command line option

2009-11-03 Thread Matthew Booth
---
 src/qemu/qemu_conf.c |2 ++
 src/qemu/qemu_conf.h |1 +
 2 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 4fd158c..e5d19ef 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -875,6 +875,8 @@ static unsigned int qemudComputeCmdFlags(const char *help,
 flags |= QEMUD_CMD_FLAG_PCIDEVICE;
 if (strstr(help, -mem-path))
 flags |= QEMUD_CMD_FLAG_MEM_PATH;
+if (strstr(help, -chardev))
+flags |= QEMUD_CMD_FLAG_CHARDEV;
 
 if (version = 9000)
 flags |= QEMUD_CMD_FLAG_VNC_COLON;
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index f9a970f..4aa764b 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -71,6 +71,7 @@ enum qemud_cmd_flags {
 QEMUD_CMD_FLAG_DRIVE_SERIAL  = (1  19), /* -driver serial=  available */
 QEMUD_CMD_FLAG_XEN_DOMID = (1  20), /* -xen-domid (new style xen 
integration) */
 QEMUD_CMD_FLAG_MIGRATE_QEMU_UNIX = (1  21), /* Does qemu support unix 
domain sockets for migration? */
+QEMUD_CMD_FLAG_CHARDEV   = (1  22), /* Is the new -chardev arg 
available */
 };
 
 /* Main driver state */
-- 
1.6.2.5

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 1/2] Detect availability of legacy QEMU -vmchannel command line option

2009-11-03 Thread Matthew Booth
* src/qemu/qemu_conf.[ch]: Detect -vmchannel command line option
---
 src/qemu/qemu_conf.c |2 ++
 src/qemu/qemu_conf.h |1 +
 2 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 0fbc190..33a55d7 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -878,6 +878,8 @@ static unsigned int qemudComputeCmdFlags(const char *help,
 flags |= QEMUD_CMD_FLAG_MEM_PATH;
 if (strstr(help, -chardev))
 flags |= QEMUD_CMD_FLAG_CHARDEV;
+if (strstr(help, -vmchannel))
+flags |= QEMUD_CMD_FLAG_VMCHANNEL;
 
 if (version = 9000)
 flags |= QEMUD_CMD_FLAG_VNC_COLON;
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 4aa764b..dc3c5c3 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -72,6 +72,7 @@ enum qemud_cmd_flags {
 QEMUD_CMD_FLAG_XEN_DOMID = (1  20), /* -xen-domid (new style xen 
integration) */
 QEMUD_CMD_FLAG_MIGRATE_QEMU_UNIX = (1  21), /* Does qemu support unix 
domain sockets for migration? */
 QEMUD_CMD_FLAG_CHARDEV   = (1  22), /* Is the new -chardev arg 
available */
+QEMUD_CMD_FLAG_VMCHANNEL = (1  23), /* Is the RHEL5-only -vmchannel 
arg available */
 };
 
 /* Main driver state */
-- 
1.6.2.5

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 2/2] Add support for legacy QEMU's -vmchannel command line option

2009-11-03 Thread Matthew Booth
This patch allows the following to be specified in a qemu domain:

channel type='unix'
  source mode='bind' path='/tmp/vmchannel'/
  target type='vmchannel' deviceid='0200'/
/channel

This will output the following on the qemu command line:

-vmchannel di:0200,unix:/tmp/vmchannel,server,nowait

* docs/schemas/domain.rng: Add syntax for vmchannel channel type
* src/conf/domain_conf.[ch]: Add domain xml support for vmchannel chrdev target
* src/qemu/qemu_conf.c: Add qemu support for vmchannel chrdev target
* tests/qemuxml2argvtest.c: Add test for vmchannel channel type
* tests/qemuxml2xmltest.c: Add test for vmchannel channel type
---
 docs/schemas/domain.rng|   13 +++-
 src/conf/domain_conf.c |   32 ++-
 src/conf/domain_conf.h |2 +
 src/qemu/qemu_conf.c   |   22 +
 .../qemuxml2argv-channel-vmchannel.args|1 +
 .../qemuxml2argv-channel-vmchannel.xml |   26 
 tests/qemuxml2argvtest.c   |1 +
 tests/qemuxml2xmltest.c|2 +
 8 files changed, 96 insertions(+), 3 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-vmchannel.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-vmchannel.xml

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index b75f17e..39a19ae 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -1059,12 +1059,23 @@
 attribute name=port/
 /element
   /define
+  define name=vmchannelTarget
+element name=target
+attribute name=type
+valuevmchannel/value
+/attribute
+attribute name=deviceid/
+/element
+  /define
   define name=channel
 element name=channel
   ref name=qemucdevSrcType/
   interleave
 ref name=qemucdevSrcDef/
-ref name=guestfwdTarget/
+choice
+  ref name=guestfwdTarget/
+  ref name=vmchannelTarget/
+/choice
   /interleave
 /element
   /define
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 4689bac..376cb3b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -134,7 +134,8 @@ VIR_ENUM_IMPL(virDomainChrTarget, 
VIR_DOMAIN_CHR_TARGET_TYPE_LAST,
   parallel,
   serial,
   console,
-  guestfwd)
+  guestfwd,
+  vmchannel)
 
 VIR_ENUM_IMPL(virDomainChr, VIR_DOMAIN_CHR_TYPE_LAST,
   null,
@@ -1349,6 +1350,7 @@ virDomainChrDefParseXML(virConnectPtr conn,
 const char *targetType = NULL;
 const char *addrStr = NULL;
 const char *portStr = NULL;
+const char *deviceidStr = NULL;
 virDomainChrDefPtr def;
 
 if (VIR_ALLOC(def)  0) {
@@ -1497,6 +1499,26 @@ virDomainChrDefParseXML(virConnectPtr conn,
 virSocketSetPort(def-target.addr, port);
 break;
 
+case VIR_DOMAIN_CHR_TARGET_TYPE_VMCHANNEL:
+deviceidStr = virXMLPropString(cur, deviceid);
+
+if(deviceidStr == NULL) {
+virDomainReportError(conn, VIR_ERR_INVALID_DOMAIN,
+ _(vmchannel channel does not 
+   define a device id));
+goto error;
+}
+
+unsigned int deviceid;
+if(virStrToLong_ui(deviceidStr, NULL, 16, deviceid)  0) {
+virDomainReportError(conn, VIR_ERR_INVALID_DOMAIN,
+ _(Invalid device id: %s),
+ deviceidStr);
+goto error;
+}
+def-target.deviceid = deviceid;
+break;
+
 default:
 virDomainReportError(conn, VIR_ERR_INVALID_DOMAIN,
  _(unexpected target type type %u),
@@ -1507,7 +1529,6 @@ virDomainChrDefParseXML(virConnectPtr conn,
 cur = cur-next;
 }
 
-
 switch (def-type) {
 case VIR_DOMAIN_CHR_TYPE_NULL:
 /* Nada */
@@ -1634,6 +1655,7 @@ cleanup:
 VIR_FREE(targetType);
 VIR_FREE(addrStr);
 VIR_FREE(portStr);
+VIR_FREE(deviceidStr);
 
 return def;
 
@@ -4118,6 +4140,7 @@ virDomainChrDefFormat(virConnectPtr conn,
 switch (def-targetType) {
 /* channel types are in a common channel element */
 case VIR_DOMAIN_CHR_TARGET_TYPE_GUESTFWD:
+case VIR_DOMAIN_CHR_TARGET_TYPE_VMCHANNEL:
 elementName = channel;
 break;
 
@@ -4230,6 +4253,11 @@ virDomainChrDefFormat(virConnectPtr conn,
   addr, port);
 break;
 
+case VIR_DOMAIN_CHR_TARGET_TYPE_VMCHANNEL:
+virBufferVSprintf(buf,   target 

[libvirt] [PATCH] network utilities: Add functions for address-text and get/set port number

2009-11-02 Thread Matthew Booth
---
 src/libvirt_private.syms |3 ++
 src/util/network.c   |   88 +-
 src/util/network.h   |6 +++
 3 files changed, 96 insertions(+), 1 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 8525dbd..15d75fd 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -289,10 +289,13 @@ virFree;
 virSocketAddrInNetwork;
 virSocketAddrIsNetmask;
 virSocketCheckNetmask;
+virSocketFormatAddr;
+virSocketGetPort;
 virSocketGetRange;
 virSocketParseAddr;
 virSocketParseIpv4Addr;
 virSocketParseIpv6Addr;
+virSocketSetPort;
 
 
 # network_conf.h
diff --git a/src/util/network.c b/src/util/network.c
index abd866c..094130f 100644
--- a/src/util/network.c
+++ b/src/util/network.c
@@ -9,6 +9,7 @@
  */
 
 #include config.h
+#include arpa/inet.h
 
 #include memory.h
 #include network.h
@@ -64,7 +65,7 @@ static int getIPv6Addr(virSocketAddrPtr addr, virIPv6AddrPtr 
tab) {
  * Mostly a wrapper for getaddrinfo() extracting the address storage
  * from the numeric string like 1.2.3.4 or 2001:db8:85a3:0:0:8a2e:370:7334
  *
- * Returns the lenght of the network address or -1 in case of error.
+ * Returns the length of the network address or -1 in case of error.
  */
 int
 virSocketParseAddr(const char *val, virSocketAddrPtr addr, int hint) {
@@ -116,6 +117,91 @@ virSocketParseIpv6Addr(const char *val, virSocketAddrPtr 
addr) {
 return(virSocketParseAddr(val, addr, AF_INET6));
 }
 
+/*
+ * virSocketFormatAddr:
+ * @addr: an initialised virSocketAddrPtr
+ *
+ * Returns a string representation of the given address
+ * Returns NULL on any error
+ * Caller must free the returned string
+ */
+char *
+virSocketFormatAddr(virSocketAddrPtr addr) {
+char   *out;
+size_t outlen;
+void   *inaddr;
+
+if (addr-stor.ss_family == AF_INET) {
+outlen = INET_ADDRSTRLEN;
+inaddr = addr-inet4.sin_addr;
+}
+
+else if (addr-stor.ss_family == AF_INET6) {
+outlen = INET6_ADDRSTRLEN;
+inaddr = addr-inet6.sin6_addr;
+}
+
+else {
+return NULL;
+}
+
+if (VIR_ALLOC_N(out, outlen)  0)
+return NULL;
+
+if (inet_ntop(addr-stor.ss_family, inaddr, out, outlen) == NULL) {
+VIR_FREE(out);
+return NULL;
+}
+
+return out;
+}
+
+/*
+ * virSocketSetPort:
+ * @addr: an initialised virSocketAddrPtr
+ * @port: the port number to set
+ *
+ * Set the transport layer port of the given virtSocketAddr
+ *
+ * Returns 0 on success, -1 on failure
+ */
+int
+virSocketSetPort(virSocketAddrPtr addr, in_port_t port) {
+if(addr-stor.ss_family == AF_INET) {
+addr-inet4.sin_port = port;
+}
+
+else if(addr-stor.ss_family == AF_INET6) {
+addr-inet6.sin6_port = port;
+}
+
+else {
+return -1;
+}
+
+return 0;
+}
+
+/*
+ * virSocketGetPort:
+ * @addr: an initialised virSocketAddrPtr
+ *
+ * Returns the transport layer port of the given virtSocketAddr
+ * Returns 0 if @addr is invalid
+ */
+in_port_t
+virSocketGetPort(virSocketAddrPtr addr) {
+if(addr-stor.ss_family == AF_INET) {
+return addr-inet4.sin_port;
+}
+
+else if(addr-stor.ss_family == AF_INET6) {
+return addr-inet6.sin6_port;
+}
+
+return 0;
+}
+
 /**
  * virSocketAddrIsNetmask:
  * @netmask: the netmask address
diff --git a/src/util/network.h b/src/util/network.h
index e590747..7618547 100644
--- a/src/util/network.h
+++ b/src/util/network.h
@@ -34,6 +34,12 @@ int virSocketParseIpv4Addr(const char *val,
 int virSocketParseIpv6Addr(const char *val,
virSocketAddrPtr addr);
 
+char * virSocketFormatAddr(virSocketAddrPtr addr);
+
+int virSocketSetPort(virSocketAddrPtr addr, in_port_t port);
+
+in_port_t virSocketGetPort(virSocketAddrPtr addr);
+
 int virSocketAddrInNetwork(virSocketAddrPtr addr1,
virSocketAddrPtr addr2,
virSocketAddrPtr netmask);
-- 
1.6.2.5

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] network utilities: Add functions for address-text and get/set port number

2009-11-02 Thread Matthew Booth
---
 src/libvirt_private.syms |3 +
 src/util/network.c   |   97 +-
 src/util/network.h   |6 +++
 3 files changed, 105 insertions(+), 1 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 8525dbd..15d75fd 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -289,10 +289,13 @@ virFree;
 virSocketAddrInNetwork;
 virSocketAddrIsNetmask;
 virSocketCheckNetmask;
+virSocketFormatAddr;
+virSocketGetPort;
 virSocketGetRange;
 virSocketParseAddr;
 virSocketParseIpv4Addr;
 virSocketParseIpv6Addr;
+virSocketSetPort;
 
 
 # network_conf.h
diff --git a/src/util/network.c b/src/util/network.c
index abd866c..674e768 100644
--- a/src/util/network.c
+++ b/src/util/network.c
@@ -9,6 +9,7 @@
  */
 
 #include config.h
+#include arpa/inet.h
 
 #include memory.h
 #include network.h
@@ -64,7 +65,7 @@ static int getIPv6Addr(virSocketAddrPtr addr, virIPv6AddrPtr 
tab) {
  * Mostly a wrapper for getaddrinfo() extracting the address storage
  * from the numeric string like 1.2.3.4 or 2001:db8:85a3:0:0:8a2e:370:7334
  *
- * Returns the lenght of the network address or -1 in case of error.
+ * Returns the length of the network address or -1 in case of error.
  */
 int
 virSocketParseAddr(const char *val, virSocketAddrPtr addr, int hint) {
@@ -116,6 +117,100 @@ virSocketParseIpv6Addr(const char *val, virSocketAddrPtr 
addr) {
 return(virSocketParseAddr(val, addr, AF_INET6));
 }
 
+/*
+ * virSocketFormatAddr:
+ * @addr: an initialised virSocketAddrPtr
+ *
+ * Returns a string representation of the given address
+ * Returns NULL on any error
+ * Caller must free the returned string
+ */
+char *
+virSocketFormatAddr(virSocketAddrPtr addr) {
+char   *out;
+size_t outlen;
+void   *inaddr;
+
+if (addr == NULL)
+return NULL;
+
+if (addr-stor.ss_family == AF_INET) {
+outlen = INET_ADDRSTRLEN;
+inaddr = addr-inet4.sin_addr;
+}
+
+else if (addr-stor.ss_family == AF_INET6) {
+outlen = INET6_ADDRSTRLEN;
+inaddr = addr-inet6.sin6_addr;
+}
+
+else {
+return NULL;
+}
+
+if (VIR_ALLOC_N(out, outlen)  0)
+return NULL;
+
+if (inet_ntop(addr-stor.ss_family, inaddr, out, outlen) == NULL) {
+VIR_FREE(out);
+return NULL;
+}
+
+return out;
+}
+
+/*
+ * virSocketSetPort:
+ * @addr: an initialised virSocketAddrPtr
+ * @port: the port number to set
+ *
+ * Set the transport layer port of the given virtSocketAddr
+ *
+ * Returns 0 on success, -1 on failure
+ */
+int
+virSocketSetPort(virSocketAddrPtr addr, int port) {
+if (addr == NULL)
+return -1;
+
+if(addr-stor.ss_family == AF_INET) {
+addr-inet4.sin_port = port;
+}
+
+else if(addr-stor.ss_family == AF_INET6) {
+addr-inet6.sin6_port = port;
+}
+
+else {
+return -1;
+}
+
+return 0;
+}
+
+/*
+ * virSocketGetPort:
+ * @addr: an initialised virSocketAddrPtr
+ *
+ * Returns the transport layer port of the given virtSocketAddr
+ * Returns -1 if @addr is invalid
+ */
+int
+virSocketGetPort(virSocketAddrPtr addr) {
+if (addr == NULL)
+return -1;
+
+if(addr-stor.ss_family == AF_INET) {
+return addr-inet4.sin_port;
+}
+
+else if(addr-stor.ss_family == AF_INET6) {
+return addr-inet6.sin6_port;
+}
+
+return -1;
+}
+
 /**
  * virSocketAddrIsNetmask:
  * @netmask: the netmask address
diff --git a/src/util/network.h b/src/util/network.h
index e590747..3762ef2 100644
--- a/src/util/network.h
+++ b/src/util/network.h
@@ -34,6 +34,12 @@ int virSocketParseIpv4Addr(const char *val,
 int virSocketParseIpv6Addr(const char *val,
virSocketAddrPtr addr);
 
+char * virSocketFormatAddr(virSocketAddrPtr addr);
+
+int virSocketSetPort(virSocketAddrPtr addr, int port);
+
+int virSocketGetPort(virSocketAddrPtr addr);
+
 int virSocketAddrInNetwork(virSocketAddrPtr addr1,
virSocketAddrPtr addr2,
virSocketAddrPtr netmask);
-- 
1.6.2.5

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] Add support for qemu's guestfwd

2009-11-02 Thread Matthew Booth
This series adds support for a vmchannel using qemu's guestfwd. I'll be
following up with support for virtio-serial and RHEL5's vmchannel.

A vmchannel is specified as:

vmchannel type='pipe'
  source path='/tmp/vmchannel'/
  target type='guestfwd' address='10.0.2.1' port='4600'/
/vmchannel

There are a couple of minor complications. Firstly, the existing chrdev
structure assumes that all front-ends take only a port. There's a bit of code
churn adding a second union to this struct to allow for different data for
different backends.

Secondly, it turns out that the existing syntax for character devices doesn't
really work for guestfwd. Specifically it won't allow common options to be
added. This is fixed in qemu git with the new -chardev syntax. Consequently,
this patch only adds support for guestfwd using -chardev. We add detection for
-chardev, and a new internal utility function to output -chardev command lines
for all existing character device backends.

Matt

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 1/4] character device: Allow character devices to have different target types

2009-11-02 Thread Matthew Booth
Currently a character device's target (it's interface in the guest) has only a
single property: port. This patch is in preparation for adding targets which
require other properties.

Target properties are moved into a union in virDomainChrDef, and a targetType
field is added to identify which union member should be used. All current code
which touches a virDomainChrDef is updated both to use the new union field,
and to populate targetType if necessary.
---
 src/conf/domain_conf.c  |   66 +-
 src/conf/domain_conf.h  |   18 +++-
 src/esx/esx_vmx.c   |   56 +--
 src/qemu/qemu_conf.c|6 +++-
 src/qemu/qemu_driver.c  |2 +
 src/uml/uml_conf.c  |   12 
 src/uml/uml_driver.c|2 +-
 src/vbox/vbox_tmpl.c|   22 
 src/xen/xend_internal.c |3 ++
 src/xen/xm_internal.c   |3 ++
 10 files changed, 129 insertions(+), 61 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index de07e13..0e49482 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -127,6 +127,13 @@ VIR_ENUM_IMPL(virDomainNet, VIR_DOMAIN_NET_TYPE_LAST,
   bridge,
   internal)
 
+VIR_ENUM_IMPL(virDomainChrTarget, VIR_DOMAIN_CHR_TARGET_TYPE_LAST,
+  null,
+  monitor,
+  parallel,
+  serial,
+  console)
+
 VIR_ENUM_IMPL(virDomainChr, VIR_DOMAIN_CHR_TYPE_LAST,
   null,
   vc,
@@ -1305,6 +1312,7 @@ virDomainChrDefParseXML(virConnectPtr conn,
 char *path = NULL;
 char *mode = NULL;
 char *protocol = NULL;
+const char *targetType = NULL;
 virDomainChrDefPtr def;
 
 if (VIR_ALLOC(def)  0) {
@@ -1318,6 +1326,21 @@ virDomainChrDefParseXML(virConnectPtr conn,
 else if ((def-type = virDomainChrTypeFromString(type))  0)
 def-type = VIR_DOMAIN_CHR_TYPE_NULL;
 
+targetType = (const char *) node-name;
+if (targetType == NULL) {
+/* Shouldn't be possible */
+virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ node-name is NULL at %s:%i,
+ __FILE__, __LINE__);
+return NULL;
+}
+if ((def-targetType = virDomainChrTargetTypeFromString(targetType))  0) {
+virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _(unknown target type for character device: %s),
+ targetType);
+def-targetType = VIR_DOMAIN_CHR_TARGET_TYPE_NULL;
+}
+
 cur = node-children;
 while (cur != NULL) {
 if (cur-type == XML_ELEMENT_NODE) {
@@ -2911,7 +2934,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr 
conn,
 if (!chr)
 goto error;
 
-chr-dstPort = i;
+chr-target.port = i;
 def-parallels[def-nparallels++] = chr;
 }
 VIR_FREE(nodes);
@@ -2931,7 +2954,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr 
conn,
 if (!chr)
 goto error;
 
-chr-dstPort = i;
+chr-target.port = i;
 def-serials[def-nserials++] = chr;
 }
 VIR_FREE(nodes);
@@ -2943,7 +2966,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr 
conn,
 if (!chr)
 goto error;
 
-chr-dstPort = 0;
+chr-target.port = 0;
 /*
  * For HVM console actually created a serial device
  * while for non-HVM it was a parvirt console
@@ -3945,10 +3968,12 @@ static int
 virDomainChrDefFormat(virConnectPtr conn,
   virBufferPtr buf,
   virDomainChrDefPtr def,
-  const char *name,
   int flags)
 {
 const char *type = virDomainChrTypeToString(def-type);
+const char *targetName = virDomainChrTargetTypeToString(def-targetType);
+
+const char *elementName = targetName; /* Currently always the same */
 
 if (!type) {
 virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
@@ -3958,8 +3983,8 @@ virDomainChrDefFormat(virConnectPtr conn,
 
 /* Compat with legacy  console tty='/dev/pts/5'/ syntax */
 virBufferVSprintf(buf, %s type='%s',
-  name, type);
-if (STREQ(name, console) 
+  elementName, type);
+if (def-targetType == VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE 
 def-type == VIR_DOMAIN_CHR_TYPE_PTY 
 !(flags  VIR_DOMAIN_XML_INACTIVE) 
 def-data.file.path) {
@@ -4034,11 +4059,23 @@ virDomainChrDefFormat(virConnectPtr conn,
 break;
 }
 
-virBufferVSprintf(buf,   target port='%d'/\n,
-  def-dstPort);
+switch (def-targetType) {
+case VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL:
+case VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL:
+case VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE:
+virBufferVSprintf(buf,   target port='%d'/\n,
+  def-target.port);

[libvirt] [PATCH 2/4] Detect availability of QEMU -chardev command line option

2009-11-02 Thread Matthew Booth
---
 src/qemu/qemu_conf.c |2 ++
 src/qemu/qemu_conf.h |1 +
 2 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 767965c..c4690b2 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -875,6 +875,8 @@ static unsigned int qemudComputeCmdFlags(const char *help,
 flags |= QEMUD_CMD_FLAG_PCIDEVICE;
 if (strstr(help, -mem-path))
 flags |= QEMUD_CMD_FLAG_MEM_PATH;
+if (strstr(help, -chardev))
+flags |= QEMUD_CMD_FLAG_CHARDEV;
 
 if (version = 9000)
 flags |= QEMUD_CMD_FLAG_VNC_COLON;
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index f9a970f..4aa764b 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -71,6 +71,7 @@ enum qemud_cmd_flags {
 QEMUD_CMD_FLAG_DRIVE_SERIAL  = (1  19), /* -driver serial=  available */
 QEMUD_CMD_FLAG_XEN_DOMID = (1  20), /* -xen-domid (new style xen 
integration) */
 QEMUD_CMD_FLAG_MIGRATE_QEMU_UNIX = (1  21), /* Does qemu support unix 
domain sockets for migration? */
+QEMUD_CMD_FLAG_CHARDEV   = (1  22), /* Is the new -chardev arg 
available */
 };
 
 /* Main driver state */
-- 
1.6.2.5

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 3/4] chardev: Add function to output -chardev options

2009-11-02 Thread Matthew Booth
Note that, on its own, this patch will generate a warning about an unused static
function.
---
 src/qemu/qemu_conf.c |   87 ++
 1 files changed, 87 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index c4690b2..3f0fbc1 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1386,6 +1386,93 @@ qemuBuildHostNetStr(virConnectPtr conn,
 return 0;
 }
 
+/* This function outputs a -chardev command line option which describes only 
the
+ * host side of the character device */
+static int qemudBuildCommandLineChrDevChardevStr(virDomainChrDefPtr dev,
+ const char *const id,
+ char *buf,
+ int buflen)
+{
+switch(dev-type) {
+case VIR_DOMAIN_CHR_TYPE_NULL:
+if (snprintf(buf, buflen, null,id=%s, id) = buflen)
+return -1;
+break;
+
+case VIR_DOMAIN_CHR_TYPE_VC:
+if (snprintf(buf, buflen, vc,id=%s, id) = buflen)
+return -1;
+break;
+
+case VIR_DOMAIN_CHR_TYPE_PTY:
+if (snprintf(buf, buflen, pty,id=%s, id) = buflen)
+return -1;
+break;
+
+case VIR_DOMAIN_CHR_TYPE_DEV:
+if (snprintf(buf, buflen, tty,id=%s,path=%s,
+ id, dev-data.file.path) = buflen)
+return -1;
+break;
+
+case VIR_DOMAIN_CHR_TYPE_FILE:
+if (snprintf(buf, buflen, file,id=%s,path=%s,
+ id, dev-data.file.path) = buflen)
+return -1;
+break;
+
+case VIR_DOMAIN_CHR_TYPE_PIPE:
+if (snprintf(buf, buflen, pipe,id=%s,path=%s,
+ id, dev-data.file.path) = buflen)
+return -1;
+break;
+
+case VIR_DOMAIN_CHR_TYPE_STDIO:
+if (snprintf(buf, buflen, stdio,id=%s, id) = buflen)
+return -1;
+break;
+
+case VIR_DOMAIN_CHR_TYPE_UDP:
+if (snprintf(buf, buflen,
+udp,id=%s,host=%s,port=%s,localaddr=%s,localport=%s,
+ id,
+ dev-data.udp.connectHost,
+ dev-data.udp.connectService,
+ dev-data.udp.bindHost,
+ dev-data.udp.bindService) = buflen)
+return -1;
+break;
+
+case VIR_DOMAIN_CHR_TYPE_TCP:
+{
+bool telnet =
+dev-data.tcp.protocol == VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET;
+
+if (snprintf(buf, buflen,
+ socket,id=%s,host=%s,port=%s%s%s,
+ id,
+ dev-data.tcp.host,
+ dev-data.tcp.service,
+ telnet ? ,telnet : ,
+ dev-data.tcp.listen ? ,server,nowait : ) = buflen)
+return -1;
+break;
+}
+
+case VIR_DOMAIN_CHR_TYPE_UNIX:
+if (snprintf(buf, buflen,
+ socket,id=%s,path=%s%s,
+ id,
+ dev-data.nix.path,
+ dev-data.nix.listen ? ,server,nowait : ) = buflen)
+return -1;
+break;
+}
+
+return 0;
+}
+
+/* This function outputs an all-in-one character device command line option */
 static int qemudBuildCommandLineChrDevStr(virDomainChrDefPtr dev,
   char *buf,
   int buflen)
-- 
1.6.2.5

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 4/4] Add support for qemu's guestfwd

2009-11-02 Thread Matthew Booth
This patch allows the following to be specified in a qemu domain:

vmchannel type='pipe'
  source path='/tmp/vmchannel'/
  target type='guestfwd' address='10.0.2.1' port='4600'/
/vmchannel

This will output the following on the qemu command line:

-chardev pipe,id=vmchannel0,path=/tmp/vmchannel \
-net user,guestfwd=tcp:10.0.2.1:4600-chardev:vmchannel0
---
 docs/schemas/domain.rng|   92 
 proxy/Makefile.am  |1 +
 src/conf/domain_conf.c |  157 +++-
 src/conf/domain_conf.h |6 +
 src/qemu/qemu_conf.c   |   55 +++
 .../qemuxml2argv-vmchannel-guestfwd.args   |1 +
 .../qemuxml2argv-vmchannel-guestfwd.xml|   26 
 tests/qemuxml2argvtest.c   |4 +-
 tests/qemuxml2xmltest.c|1 +
 9 files changed, 305 insertions(+), 38 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-vmchannel-guestfwd.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-vmchannel-guestfwd.xml

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index 0a6ab61..54bbdd8 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -930,6 +930,19 @@
   definition doesn't fully specify the constraints on this node.
 --
   define name=qemucdev
+ref name=qemucdevSrcType/
+interleave
+  ref name=qemucdevSrcDef/
+  optional
+element name=target
+  optional
+attribute name=port/
+  /optional
+/element
+  /optional
+/interleave
+  /define
+  define name=qemucdevSrcType
 attribute name=type
   choice
 valuedev/value
@@ -944,43 +957,36 @@
 valuepty/value
   /choice
 /attribute
-interleave
-  optional
-oneOrMore
-  element name=source
-optional
-  attribute name=mode/
-/optional
-optional
-  attribute name=path/
-/optional
-optional
-  attribute name=host/
-/optional
-optional
-  attribute name=service/
-/optional
-optional
-  attribute name=wiremode/
-/optional
-  /element
-/oneOrMore
-  /optional
-  optional
-element name=protocol
+  /define
+  define name=qemucdevSrcDef
+optional
+  oneOrMore
+element name=source
   optional
-attribute name=type/
+attribute name=mode/
   /optional
-/element
-  /optional
-  optional
-element name=target
   optional
-attribute name=port/
+attribute name=path/
+  /optional
+  optional
+attribute name=host/
+  /optional
+  optional
+attribute name=service/
+  /optional
+  optional
+attribute name=wiremode/
   /optional
 /element
-  /optional
-/interleave
+  /oneOrMore
+/optional
+optional
+  element name=protocol
+optional
+  attribute name=type/
+/optional
+  /element
+/optional
   /define
   !--
   The description for a console
@@ -1044,6 +1050,27 @@
   ref name=qemucdev/
 /element
   /define
+  define name=vmchannel
+element name=vmchannel
+  ref name=qemucdevSrcType/
+  interleave
+ref name=qemucdevSrcDef/
+element name=target
+  attribute name=type
+choice
+  valueguestfwd/value
+/choice
+  /attribute
+  optional
+attribute name=address/
+  /optional
+  optional
+attribute name=port/
+  /optional
+/element
+  /interleave
+/element
+  /define
   define name=input
 element name=input
   attribute name=type
@@ -1158,6 +1185,7 @@
 ref name=console/
 ref name=parallel/
 ref name=serial/
+ref name=vmchannel/
   /choice
 /zeroOrMore
 optional
diff --git a/proxy/Makefile.am b/proxy/Makefile.am
index 3e0050b..42f6a81 100644
--- a/proxy/Makefile.am
+++ b/proxy/Makefile.am
@@ -17,6 +17,7 @@ libvirt_proxy_SOURCES = libvirt_proxy.c \
 @top_srcdir@/src/util/buf.c \
@top_srcdir@/src/util/logging.c \
 @top_srcdir@/src/util/memory.c \
+@top_srcdir@/src/util/network.c \
@top_srcdir@/src/util/threads.c  \
 @top_srcdir@/src/util/util.c \
@top_srcdir@/src/util/uuid.c \
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0e49482..7708a75 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -40,6 +40,7 @@
 #include buf.h
 #include c-ctype.h
 #include logging.h
+#include network.h
 
 

[libvirt] [REPOST] Fix --with-init-script configure option

2009-11-02 Thread Matthew Booth
Looks like this one might have dropped off the radar.

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] Fix --with-init-script configure option

2009-11-02 Thread Matthew Booth
The --with-init-script configure option was broken, and always defaulted based
on the existence of /etc/redhat-release. This was a systematic typo based on
mixed use of init-script and init-scripts.
---
 configure.in   |   14 +++---
 daemon/Makefile.am |4 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/configure.in b/configure.in
index 04f6dfe..5987211 100644
--- a/configure.in
+++ b/configure.in
@@ -243,17 +243,17 @@ dnl init script flavor
 dnl
 AC_MSG_CHECKING([for init script flavor])
 AC_ARG_WITH([init-script],
-[AC_HELP_STRING([--with-init-scripts=[redhat|auto|none]],
-[Style of init scripts to install (defaults to auto)])])
-if test x$with_init_scripts = x -o x$with_init_scripts = xauto; then
+[AC_HELP_STRING([--with-init-script=[redhat|auto|none]],
+[Style of init script to install (defaults to auto)])])
+if test x$with_init_script = x -o x$with_init_script = xauto; then
 if test -f /etc/redhat-release ; then
-with_init_scripts=redhat
+with_init_script=redhat
 else
-with_init_scripts=none
+with_init_script=none
 fi
 fi
-AM_CONDITIONAL([LIBVIRT_INIT_SCRIPTS_RED_HAT], test x$with_init_scripts = 
xredhat)
-AC_MSG_RESULT($with_init_scripts)
+AM_CONDITIONAL([LIBVIRT_INIT_SCRIPT_RED_HAT], test x$with_init_script = 
xredhat)
+AC_MSG_RESULT($with_init_script)
 
 dnl RHEL-5 has a peculiar version of Xen, which requires some special casing
 AC_ARG_WITH([rhel5-api],
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 84aab04..ab3f238 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -188,7 +188,7 @@ install-logrotate: libvirtd.logrotate
mkdir -p $(DESTDIR)$(sysconfdir)/logrotate.d/
$(INSTALL_DATA) $ $(DESTDIR)$(sysconfdir)/logrotate.d/libvirtd
 
-if LIBVIRT_INIT_SCRIPTS_RED_HAT
+if LIBVIRT_INIT_SCRIPT_RED_HAT
 install-init: libvirtd.init
mkdir -p $(DESTDIR)$(sysconfdir)/rc.d/init.d
$(INSTALL_SCRIPT) libvirtd.init \
@@ -222,7 +222,7 @@ install-init:
 uninstall-init:
 libvirtd.init:
 
-endif # DBUS_INIT_SCRIPTS_RED_HAT
+endif # LIBVIRT_INIT_SCRIPT_RED_HAT
 
 # This must be added last, since functions it provides/replaces
 # are used by nearly every other library.
-- 
1.6.2.5

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 1/2] Add internal symbols for util/network.c

2009-10-30 Thread Matthew Booth
* src/libvirt_private.syms: Add symbols added in 24c8fc5d
---
 src/libvirt_private.syms |   10 ++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 3997704..96c2b3b 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -285,6 +285,16 @@ virReallocN;
 virFree;
 
 
+# network.h
+virSocketParseAddr;
+virSocketParseIpv4Addr;
+virSocketParseIpv6Addr;
+virSocketAddrInNetwork;
+virSocketGetRange;
+virSocketAddrIsNetmask;
+virSocketCheckNetmask;
+
+
 # network_conf.h
 virNetworkAssignDef;
 virNetworkConfigFile;
-- 
1.6.2.5

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 2/2] src/util/network.c: Fix typos in comments

2009-10-30 Thread Matthew Booth
---
 src/util/network.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/util/network.c b/src/util/network.c
index 8581cdc..abd866c 100644
--- a/src/util/network.c
+++ b/src/util/network.c
@@ -91,11 +91,11 @@ virSocketParseAddr(const char *val, virSocketAddrPtr addr, 
int hint) {
 /*
  * virSocketParseIpv4Addr:
  * @val: an IPv4 numeric address
- * @addr: the loacation to store the result
+ * @addr: the location to store the result
  *
  * Extract the address storage from an IPv4 numeric address
  *
- * Returns the lenght of the network address or -1 in case of error.
+ * Returns the length of the network address or -1 in case of error.
  */
 int
 virSocketParseIpv4Addr(const char *val, virSocketAddrPtr addr) {
@@ -105,11 +105,11 @@ virSocketParseIpv4Addr(const char *val, virSocketAddrPtr 
addr) {
 /*
  * virSocketParseIpv6Addr:
  * @val: an IPv6 numeric address
- * @addr: the loacation to store the result
+ * @addr: the location to store the result
  *
  * Extract the address storage from an IPv6 numeric address
  *
- * Returns the lenght of the network address or -1 in case of error.
+ * Returns the length of the network address or -1 in case of error.
  */
 int
 virSocketParseIpv6Addr(const char *val, virSocketAddrPtr addr) {
-- 
1.6.2.5

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] Fix --with-init-script configure option

2009-10-27 Thread Matthew Booth
The --with-init-script configure option was broken, and always defaulted based
on the existence of /etc/redhat-release. This was a systematic typo based on
mixed use of init-script and init-scripts.
---
 configure.in   |   14 +++---
 daemon/Makefile.am |4 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/configure.in b/configure.in
index 2f9db72..42ed29b 100644
--- a/configure.in
+++ b/configure.in
@@ -243,17 +243,17 @@ dnl init script flavor
 dnl
 AC_MSG_CHECKING([for init script flavor])
 AC_ARG_WITH([init-script],
-[AC_HELP_STRING([--with-init-scripts=[redhat|auto|none]],
-[Style of init scripts to install (defaults to auto)])])
-if test x$with_init_scripts = x -o x$with_init_scripts = xauto; then
+[AC_HELP_STRING([--with-init-script=[redhat|auto|none]],
+[Style of init script to install (defaults to auto)])])
+if test x$with_init_script = x -o x$with_init_script = xauto; then
 if test -f /etc/redhat-release ; then
-with_init_scripts=redhat
+with_init_script=redhat
 else
-with_init_scripts=none
+with_init_script=none
 fi
 fi
-AM_CONDITIONAL([LIBVIRT_INIT_SCRIPTS_RED_HAT], test x$with_init_scripts = 
xredhat)
-AC_MSG_RESULT($with_init_scripts)
+AM_CONDITIONAL([LIBVIRT_INIT_SCRIPT_RED_HAT], test x$with_init_script = 
xredhat)
+AC_MSG_RESULT($with_init_script)
 
 dnl RHEL-5 has a peculiar version of Xen, which requires some special casing
 AC_ARG_WITH([rhel5-api],
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 84aab04..ab3f238 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -188,7 +188,7 @@ install-logrotate: libvirtd.logrotate
mkdir -p $(DESTDIR)$(sysconfdir)/logrotate.d/
$(INSTALL_DATA) $ $(DESTDIR)$(sysconfdir)/logrotate.d/libvirtd
 
-if LIBVIRT_INIT_SCRIPTS_RED_HAT
+if LIBVIRT_INIT_SCRIPT_RED_HAT
 install-init: libvirtd.init
mkdir -p $(DESTDIR)$(sysconfdir)/rc.d/init.d
$(INSTALL_SCRIPT) libvirtd.init \
@@ -222,7 +222,7 @@ install-init:
 uninstall-init:
 libvirtd.init:
 
-endif # DBUS_INIT_SCRIPTS_RED_HAT
+endif # LIBVIRT_INIT_SCRIPT_RED_HAT
 
 # This must be added last, since functions it provides/replaces
 # are used by nearly every other library.
-- 
1.6.2.5

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list