All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andres Lagar-Cavilla <andres@lagarcavilla.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	xen-devel@lists.xensource.com
Subject: [PATCH 05/14]: libxenlight, fix uuid code
Date: Mon, 30 Nov 2009 14:12:37 -0500	[thread overview]
Message-ID: <4B141925.6030201@lagarcavilla.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 188 bytes --]

Fix uuid code:

- Use proper constants
- Use functions from the uuid library
- Fix broken pointer handling in libxl_dominfo

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.com>


[-- Attachment #2: 05_fix_uuid_code.patch --]
[-- Type: text/x-patch, Size: 3348 bytes --]

# HG changeset patch
# User Andres Lagar-Cavilla <andres@lagarcavilla.com>
# Date 1259255925 18000
# Node ID 61ad75e6a95c2ee8c6cb2f18c7eaec51ea6de785
# Parent  e882707083babfac1a55e5351cffa790a8570d7f
Fix uuid code:

- Use proper constants 
- Use functions from the uuid library
- Fix broken pointer handling in libxl_dominfo

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.com>

diff -r e882707083ba -r 61ad75e6a95c libxl.c
--- a/libxl.c
+++ b/libxl.c
@@ -279,7 +279,7 @@ redo:
             ptr = ptr2;
             size *= 2;
         }
-        memcpy(ptr[index].uuid, info[i].handle, 16 * sizeof(uint8_t));
+        memcpy(&(ptr[index].uuid), info[i].handle, sizeof(xen_domain_handle_t));
         ptr[index].domid = info[i].domain;
         first_domain = info[i].domain + 1;
         index++;
@@ -441,7 +441,7 @@ static int libxl_destroy_device_model(st
 
 int libxl_domain_destroy(struct libxl_ctx *ctx, uint32_t domid, int force)
 {
-    char *dom_path, vm_path[41];
+    char *dom_path, vm_path[UUID_LEN_STR + 5];
     xen_uuid_t *uuid;
     int rc, hvm;
 
diff -r e882707083ba -r 61ad75e6a95c libxl.h
--- a/libxl.h
+++ b/libxl.h
@@ -28,7 +28,7 @@
 typedef void (*libxl_log_callback)(void *userdata, int loglevel, const char *file,
                                    int line, const char *func, char *s);
 struct libxl_dominfo {
-    xen_uuid_t uuid[16];
+    xen_uuid_t uuid;
     uint32_t domid;
 };
 
diff -r e882707083ba -r 61ad75e6a95c libxl_utils.c
--- a/libxl_utils.c
+++ b/libxl_utils.c
@@ -92,7 +92,7 @@ int libxl_uuid_to_domid(struct libxl_ctx
     int nb_domain, i;
     struct libxl_dominfo *info = libxl_domain_list(ctx, &nb_domain);
     for (i = 0; i < nb_domain; i++) {
-        if (!memcmp(info[i].uuid, uuid, 16)) {
+        if (!xen_uuid_compare(&(info[i].uuid), uuid)) {
             *domid = info[i].domid;
             free(info);
             return 0;
@@ -108,8 +108,8 @@ int libxl_domid_to_uuid(struct libxl_ctx
     struct libxl_dominfo *info = libxl_domain_list(ctx, &nb_domain);
     for (i = 0; i < nb_domain; i++) {
         if (domid == info[i].domid) {
-            *uuid = libxl_zalloc(ctx, 16);
-            memcpy(*uuid, info[i].uuid, 16);
+            *uuid = libxl_zalloc(ctx, sizeof(xen_uuid_t));
+            xen_uuid_copy(*uuid, &(info[i].uuid));
             free(info);
             return 0;
         }
@@ -121,9 +121,9 @@ int libxl_domid_to_uuid(struct libxl_ctx
 int libxl_is_uuid(char *s)
 {
     int i;
-    if (!s || strlen(s) != 36)
+    if (!s || strlen(s) != UUID_LEN_STR)
         return 0;
-    for (i = 0; i < 36; i++) {
+    for (i = 0; i < UUID_LEN_STR; i++) {
         if (i == 8 || i == 13 || i == 18 || i == 23) {
             if (s[i] != '-')
                 return 0;
@@ -147,7 +147,7 @@ xen_uuid_t *libxl_string_to_uuid(struct 
 
 char *libxl_uuid_to_string(struct libxl_ctx *ctx, xen_uuid_t *uuid)
 {
-    char uuid_str[39];
+    char uuid_str[UUID_LEN_STR + 3];
     if (!uuid)
         return NULL;
     xen_uuid_to_string(uuid, uuid_str, sizeof(uuid_str));
diff -r e882707083ba -r 61ad75e6a95c xen_uuid.h
--- a/xen_uuid.h
+++ b/xen_uuid.h
@@ -128,4 +128,8 @@ static inline int xen_uuid_compare(xen_u
 
 #endif
 
+#ifndef UUID_LEN_STR
+#define UUID_LEN_STR  (128 /*bit*/ / 4 /*nibbles*/ + 4 /*hyphens*/)
+#endif /* UUID_LEN_STR */
+
 #endif /* __XEN_UUID_H__ */

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

                 reply	other threads:[~2009-11-30 19:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B141925.6030201@lagarcavilla.com \
    --to=andres@lagarcavilla.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.