[Libvir] [PATCH] Add xen and hvm guest types to test drive caps

The attached patch adds xen and hvm guest types to the test driver's capabilities. It was currently set to offer only a 'linux' type which doesn't seem to follow the conventions of the other drivers, so I removed that. Please yell if I'm wrong :) Thanks, Cole diff --git a/src/test.c b/src/test.c index f401d7d..9b2ca56 100644 --- a/src/test.c +++ b/src/test.c @@ -984,6 +984,8 @@ static char *testGetCapabilities (virConnectPtr conn) char *xml; int cell1[] = { 0, 2, 4, 6, 8, 10, 12, 14 }; int cell2[] = { 1, 3, 5, 7, 9, 11, 13, 15 }; + const char *guest_types[] = { "hvm", "xen" }; + int num_guest_types = 2, i; if ((caps = virCapabilitiesNew(TEST_MODEL, 0, 0)) == NULL) goto no_memory; @@ -998,29 +1000,33 @@ static char *testGetCapabilities (virConnectPtr conn) if (virCapabilitiesAddHostNUMACell(caps, 1, 8, cell2) < 0) goto no_memory; - if ((guest = virCapabilitiesAddGuest(caps, - "linux", - TEST_MODEL, - TEST_MODEL_WORDSIZE, - NULL, - NULL, - 0, - NULL)) == NULL) - goto no_memory; - - if (virCapabilitiesAddGuestDomain(guest, - "test", - NULL, - NULL, - 0, - NULL) == NULL) - goto no_memory; - - - if (virCapabilitiesAddGuestFeature(guest, "pae", 1, 1) == NULL) - goto no_memory; - if (virCapabilitiesAddGuestFeature(guest ,"nonpae", 1, 1) == NULL) - goto no_memory; + for (i = 0; i < num_guest_types; ++i) { + + if ((guest = virCapabilitiesAddGuest(caps, + guest_types[i], + TEST_MODEL, + TEST_MODEL_WORDSIZE, + NULL, + NULL, + 0, + NULL)) == NULL) + goto no_memory; + + if (virCapabilitiesAddGuestDomain(guest, + "test", + NULL, + NULL, + 0, + NULL) == NULL) + goto no_memory; + + if (strcmp(guest_types[i], "xen")) { + if (virCapabilitiesAddGuestFeature(guest, "pae", 1, 1) == NULL) + goto no_memory; + if (virCapabilitiesAddGuestFeature(guest ,"nonpae", 1, 1) == NULL) + goto no_memory; + } + } if ((xml = virCapabilitiesFormatXML(caps)) == NULL) goto no_memory;

On Tue, Mar 04, 2008 at 04:17:34PM -0500, Cole Robinson wrote:
The attached patch adds xen and hvm guest types to the test driver's capabilities. It was currently set to offer only a 'linux' type which doesn't seem to follow the conventions of the other drivers, so I removed that. Please yell if I'm wrong :)
THis patch all seems fine to me. The only problem you'll likely hit is that the domain XML parser won't like the full-virt style <os> block where you list a <boot> tag instead of kernel/initrd. Of course you can do HVM + kernel/initrd too, so I've no problem adding this patch - just that we'll likely need to add more XML parsing support to the test driver to give full coverage of the HVM style configs.
@@ -984,6 +984,8 @@ static char *testGetCapabilities (virConnectPtr conn) char *xml; int cell1[] = { 0, 2, 4, 6, 8, 10, 12, 14 }; int cell2[] = { 1, 3, 5, 7, 9, 11, 13, 15 }; + const char *guest_types[] = { "hvm", "xen" }; + int num_guest_types = 2, i;
Having a 'num_guest_types' variable is not neccessary...
+ for (i = 0; i < num_guest_types; ++i) {
Just use 'sizeof(guest_types)/sizeof(guest_types[0])' instead Regards, Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|

Daniel P. Berrange wrote:
On Tue, Mar 04, 2008 at 04:17:34PM -0500, Cole Robinson wrote:
The attached patch adds xen and hvm guest types to the test driver's capabilities. It was currently set to offer only a 'linux' type which doesn't seem to follow the conventions of the other drivers, so I removed that. Please yell if I'm wrong :)
THis patch all seems fine to me. The only problem you'll likely hit is that the domain XML parser won't like the full-virt style <os> block where you list a <boot> tag instead of kernel/initrd. Of course you can do HVM + kernel/initrd too, so I've no problem adding this patch - just that we'll likely need to add more XML parsing support to the test driver to give full coverage of the HVM style configs.
@@ -984,6 +984,8 @@ static char *testGetCapabilities (virConnectPtr conn) char *xml; int cell1[] = { 0, 2, 4, 6, 8, 10, 12, 14 }; int cell2[] = { 1, 3, 5, 7, 9, 11, 13, 15 }; + const char *guest_types[] = { "hvm", "xen" }; + int num_guest_types = 2, i;
Having a 'num_guest_types' variable is not neccessary...
+ for (i = 0; i < num_guest_types; ++i) {
Just use 'sizeof(guest_types)/sizeof(guest_types[0])' instead
Regards, Dan.
I forgot to resend this :/ The attached patch adds the above simplification and is diff'd against the current codebase. Still haven't looked at actually parsing the hvm guest xml, but that part isn't neccessary for this change to be useful for the userspace tools (currently you cannot run virt-install with the test driver without this change). Thanks, Cole diff --git a/src/test.c b/src/test.c index 135d96f..0a3779a 100644 --- a/src/test.c +++ b/src/test.c @@ -1006,6 +1006,7 @@ static char *testGetCapabilities (virConnectPtr conn) virCapsPtr caps; virCapsGuestPtr guest; char *xml; + const char *guest_types[] = { "hvm", "xen" }; int i; GET_CONNECTION(conn, -1); @@ -1024,29 +1025,31 @@ static char *testGetCapabilities (virConnectPtr conn) goto no_memory; } - if ((guest = virCapabilitiesAddGuest(caps, - "linux", - TEST_MODEL, - TEST_MODEL_WORDSIZE, - NULL, - NULL, - 0, - NULL)) == NULL) - goto no_memory; + for (i = 0; i < (sizeof(guest_types)/sizeof(guest_types[0])); ++i) { - if (virCapabilitiesAddGuestDomain(guest, - "test", - NULL, - NULL, - 0, - NULL) == NULL) - goto no_memory; + if ((guest = virCapabilitiesAddGuest(caps, + guest_types[i], + TEST_MODEL, + TEST_MODEL_WORDSIZE, + NULL, + NULL, + 0, + NULL)) == NULL) + goto no_memory; + if (virCapabilitiesAddGuestDomain(guest, + "test", + NULL, + NULL, + 0, + NULL) == NULL) + goto no_memory; - if (virCapabilitiesAddGuestFeature(guest, "pae", 1, 1) == NULL) - goto no_memory; - if (virCapabilitiesAddGuestFeature(guest ,"nonpae", 1, 1) == NULL) - goto no_memory; + if (virCapabilitiesAddGuestFeature(guest, "pae", 1, 1) == NULL) + goto no_memory; + if (virCapabilitiesAddGuestFeature(guest ,"nonpae", 1, 1) == NULL) + goto no_memory; + } if ((xml = virCapabilitiesFormatXML(caps)) == NULL) goto no_memory;

This patch looks good to me. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v

On Fri, Apr 04, 2008 at 10:47:08AM -0400, Cole Robinson wrote:
Daniel P. Berrange wrote:
On Tue, Mar 04, 2008 at 04:17:34PM -0500, Cole Robinson wrote:
The attached patch adds xen and hvm guest types to the test driver's capabilities. It was currently set to offer only a 'linux' type which doesn't seem to follow the conventions of the other drivers, so I removed that. Please yell if I'm wrong :)
THis patch all seems fine to me. The only problem you'll likely hit is that the domain XML parser won't like the full-virt style <os> block where you list a <boot> tag instead of kernel/initrd. Of course you can do HVM + kernel/initrd too, so I've no problem adding this patch - just that we'll likely need to add more XML parsing support to the test driver to give full coverage of the HVM style configs.
@@ -984,6 +984,8 @@ static char *testGetCapabilities (virConnectPtr conn) char *xml; int cell1[] = { 0, 2, 4, 6, 8, 10, 12, 14 }; int cell2[] = { 1, 3, 5, 7, 9, 11, 13, 15 }; + const char *guest_types[] = { "hvm", "xen" }; + int num_guest_types = 2, i;
Having a 'num_guest_types' variable is not neccessary...
+ for (i = 0; i < num_guest_types; ++i) {
Just use 'sizeof(guest_types)/sizeof(guest_types[0])' instead
Regards, Dan.
I forgot to resend this :/
And i forgot to apply it ;-) Looks good, this is now in CVS, thanks ! Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
participants (4)
-
Cole Robinson
-
Daniel P. Berrange
-
Daniel Veillard
-
Richard W.M. Jones