[Libvir] [PATCH] patch for virsh domname <uuid> command error

Hi, Virsh domname <uuid> command for shut-off domain fails on xen-3.0.4. I think that xm_internal.c shoud be modified. But, it seems that xm_internal's structure isn't for xen-3.0.4, and shut-off domain's information is got from xend. I make a patch for xend_internal.c The attached patch resolve this issue in the following way: 1) If the domain's name can't be pulled out from the running domains list by uuid, request xend by "/xend/domains/<uuid>". 2) If the domain's data can be teken from xend, pull out the domain's name. Signed-off-by: Tatsuro Enokura <fj7716hz@aa.jp.fujitsu.com> Thanks, Tatsuro Enokura. Index: src/xend_internal.c (libvirt-0.2.0) =================================================================== --- xend_internal.c 2007-02-15 01:16:16.000000000 +0900 +++ xend_internal.c.new 2007-02-23 21:13:22.000000000 +0900 @@ -2759,6 +2759,8 @@ xenDaemonLookupByUUID(virConnectPtr conn char **tmp; unsigned char ident[VIR_UUID_BUFLEN]; int id = -1; + struct sexpr *root = NULL; + char *domname = NULL; names = xenDaemonListDomainsOld(conn); tmp = names; @@ -2779,6 +2781,26 @@ xenDaemonLookupByUUID(virConnectPtr conn } free(names); + if (name == NULL) { + char uuidstr[VIR_UUID_STRING_BUFLEN]; + memset(uuidstr, '\0', VIR_UUID_STRING_BUFLEN); + + snprintf(uuidstr, VIR_UUID_STRING_BUFLEN, + "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", + uuid[0], uuid[1], uuid[2], uuid[3], + uuid[4], uuid[5], uuid[6], uuid[7], + uuid[8], uuid[9], uuid[10], uuid[11], + uuid[12], uuid[13], uuid[14], uuid[15]); + root = sexpr_get(conn, "/xend/domain/%s?detail=1", uuidstr); + if (root == NULL) + goto error; + domname = (char*)sexpr_node(root, "domain/name"); + if (domname == NULL) + goto error; + name = strdup(domname); + id = -1; + } + if (name == NULL) goto error; @@ -2793,6 +2815,8 @@ xenDaemonLookupByUUID(virConnectPtr conn return (ret); error: + if (root != NULL) + sexpr_free(root); if (name != NULL) free(name); return (NULL); ===================================================================

On Fri, Feb 23, 2007 at 06:59:41PM +0900, Tatsuro Enokura wrote:
Virsh domname <uuid> command for shut-off domain fails on xen-3.0.4.
I think that xm_internal.c shoud be modified. But, it seems that xm_internal's structure isn't for xen-3.0.4,
Yes, that's correct - xm_internal.c is a backwards compatability driver for Xen <= 3.0.3 which didn't support inactivate domains.
and shut-off domain's information is got from xend. I make a patch for xend_internal.c
The attached patch resolve this issue in the following way:
1) If the domain's name can't be pulled out from the running domains list by uuid, request xend by "/xend/domains/<uuid>". 2) If the domain's data can be teken from xend, pull out the domain's name.
It looks like a reasonable patch - I'll do a little testing and if it works on Fedora 7 I'll add it to CVS. 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 -=|

Hi, Dan Daniel P. Berrange wrote:
and shut-off domain's information is got from xend. I make a patch for xend_internal.c
The attached patch resolve this issue in the following way:
1) If the domain's name can't be pulled out from the running domains list by uuid, request xend by "/xend/domains/<uuid>". 2) If the domain's data can be teken from xend, pull out the domain's name.
It looks like a reasonable patch - I'll do a little testing and if it works on Fedora 7 I'll add it to CVS.
Could you tell me the test result on this patch? If the test is fine, please commit it. Thanks, Tatusro Enokura.

On Thu, Mar 01, 2007 at 06:11:44PM +0900, Tatsuro Enokura wrote:
Hi, Dan
Daniel P. Berrange wrote:
and shut-off domain's information is got from xend. I make a patch for xend_internal.c
The attached patch resolve this issue in the following way:
1) If the domain's name can't be pulled out from the running domains list by uuid, request xend by "/xend/domains/<uuid>". 2) If the domain's data can be teken from xend, pull out the domain's name.
It looks like a reasonable patch - I'll do a little testing and if it works on Fedora 7 I'll add it to CVS.
Could you tell me the test result on this patch? If the test is fine, please commit it.
So, in previous XenD you were not able to request a domain based on UUID, eg GET /xen/domain/3ef946bb4d5033a8cdba29f405de11ea was not a valid URL served by XenD. So we basically did a get on /xen/domain/ to build a list of names, and then iterate over them, fetching each one in turn until we found the one we wanted. This is obviously horribly slow, but the only option we had on Xen < 3.0.4 Now, that XenD does allow lookups based on UUID, I am changing your patch so that it *always* does the lookup based on UUID, so that we avoid the slow path completely on Xen >= 3.0.4 I propose to apply the attached patch version - anyone else with comments ? 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 -=|

Hi, Dan Daniel P. Berrange wrote:
and shut-off domain's information is got from xend. I make a patch for xend_internal.c
The attached patch resolve this issue in the following way:
1) If the domain's name can't be pulled out from the running domains list by uuid, request xend by "/xend/domains/<uuid>". 2) If the domain's data can be teken from xend, pull out the domain's name. It looks like a reasonable patch - I'll do a little testing and if it works on Fedora 7 I'll add it to CVS. Could you tell me the test result on this patch? If the test is fine, please commit it.
So, in previous XenD you were not able to request a domain based on UUID,
eg GET /xen/domain/3ef946bb4d5033a8cdba29f405de11ea
was not a valid URL served by XenD. So we basically did a get on /xen/domain/ to build a list of names, and then iterate over them, fetching each one in turn until we found the one we wanted. This is obviously horribly slow, but the only option we had on Xen < 3.0.4
Now, that XenD does allow lookups based on UUID, I am changing your patch so that it *always* does the lookup based on UUID, so that we avoid the slow path completely on Xen >= 3.0.4
I propose to apply the attached patch version - anyone else with comments ?
Thank you for your reply, I think that your partch is more better. Thanks, Tatsuro Enokura
participants (2)
-
Daniel P. Berrange
-
Tatsuro Enokura