Skip to contentSkip to conversation

libxenlight resend: avoid writing empty values to xenstore

PATCH In review Andres Lagar-Cavilla 2 participants 3 messages Dec 2, 2009 – Dec 3, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 4/7 libxenlight resend: avoid writing empty values to xenstore

This is not a resend strictly speaking, rather an extension of a patch accepted previously

-------------------------------

Prevent segmentation fault caused by empty values in key-value pairs for the /vm/ subdirectory when restoring a pv domain.

# HG changeset patch
# User Andres Lagar-Cavilla <[email protected]> # Date 1259765969 18000
# Node ID 3d56de009e4233b872a147db8b100cec22dfcfaf # Parent 2cb7689c60c959f9d9aa29ce5d285486c5a011df Prevent segmentation fault caused by empty values in key-value pairs for the /vm/ subdirectory when restoring a pv domain.

libxl.c +14 -8
diff -r 2cb7689c60c9 -r 3d56de009e42 libxl.c
@@ -229,6 +229,7 @@ int libxl_domain_restore(struct libxl_ct
                          libxl_device_model_info *dm_info)
 {
     char **vments = NULL, **localents = NULL;
+    int i;
 
     build_pre(ctx, domid, info, state);
     restore_common(ctx, domid, info, state, fd);
@@ -240,14 +241,19 @@ int libxl_domain_restore(struct libxl_ct
         vments[3] = "hvm";
     } else {
         vments = libxl_calloc(ctx, 9, sizeof(char *));
-        vments[0] = "image/ostype";
-        vments[1] = "linux";
-        vments[2] = "image/kernel";
-        vments[3] = (char*) info->kernel;
-        vments[4] = "image/ramdisk";
-        vments[5] = (char*) info->u.pv.ramdisk;
-        vments[6] = "image/cmdline";
-        vments[7] = (char*) info->u.pv.cmdline;
+        i = 0;
+        vments[i++] = "image/ostype";
+        vments[i++] = "linux";
+        vments[i++] = "image/kernel";
+        vments[i++] = (char*) info->kernel;
+        if (info->u.pv.ramdisk) {
+            vments[i++] = "image/ramdisk";
+            vments[i++] = (char*) info->u.pv.ramdisk;
+        }
+        if (info->u.pv.cmdline) {
+            vments[i++] = "image/cmdline";
+            vments[i++] = (char*) info->u.pv.cmdline;
+        }
     }
     build_post(ctx, domid, info, state, vments, localents);
     if (info->hvm)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw

PATCH 4/7 libxenlight meta-resend: avoid writing empty values to xenstore

In reply to Andres Lagar-Cavilla

This is not a resend strictly speaking, rather an extension of a patch accepted previously

-------------------------------

Prevent segmentation fault caused by empty values in key-value pairs for the /vm/ subdirectory when restoring a pv domain.

# HG changeset patch
# User Andres Lagar-Cavilla <[email protected]> # Date 1259765969 18000
# Node ID 3d56de009e4233b872a147db8b100cec22dfcfaf # Parent 2cb7689c60c959f9d9aa29ce5d285486c5a011df Prevent segmentation fault caused by empty values in key-value pairs for the /vm/ subdirectory when restoring a pv domain.

libxl.c +14 -8
diff -r 2cb7689c60c9 -r 3d56de009e42 libxl.c
@@ -229,6 +229,7 @@ int libxl_domain_restore(struct libxl_ct
                          libxl_device_model_info *dm_info)
 {
     char **vments = NULL, **localents = NULL;
+    int i;
 
     build_pre(ctx, domid, info, state);
     restore_common(ctx, domid, info, state, fd);
@@ -240,14 +241,19 @@ int libxl_domain_restore(struct libxl_ct
         vments[3] = "hvm";
     } else {
         vments = libxl_calloc(ctx, 9, sizeof(char *));
-        vments[0] = "image/ostype";
-        vments[1] = "linux";
-        vments[2] = "image/kernel";
-        vments[3] = (char*) info->kernel;
-        vments[4] = "image/ramdisk";
-        vments[5] = (char*) info->u.pv.ramdisk;
-        vments[6] = "image/cmdline";
-        vments[7] = (char*) info->u.pv.cmdline;
+        i = 0;
+        vments[i++] = "image/ostype";
+        vments[i++] = "linux";
+        vments[i++] = "image/kernel";
+        vments[i++] = (char*) info->kernel;
+        if (info->u.pv.ramdisk) {
+            vments[i++] = "image/ramdisk";
+            vments[i++] = (char*) info->u.pv.ramdisk;
+        }
+        if (info->u.pv.cmdline) {
+            vments[i++] = "image/cmdline";
+            vments[i++] = (char*) info->u.pv.cmdline;
+        }
     }
     build_post(ctx, domid, info, state, vments, localents);
     if (info->hvm)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel