[Libguestfs] [PATCH 4/4] actions/part_set_gpt_type: set type of "guid" parameter as "GUID" (RHBZ#1008417).

Pino Toscano ptoscano at redhat.com
Mon Feb 10 10:12:11 UTC 2014


Switch the type of the "guid" parameter from "String" to "GUID"; this
adds the validation of the GUID as such, rejecting straight away invalid
GUIDs which otherwise could be handled badly by low-level tools (such as
sgdisk).

Add a couple of easy tests (taken from RHBZ#1008417) to
part_set_gpt_type about this.
---
 generator/actions.ml | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/generator/actions.ml b/generator/actions.ml
index b665149..a6ef194 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -11339,9 +11339,18 @@ group with GUID C<diskgroup>." };
 
   { defaults with
     name = "part_set_gpt_type";
-    style = RErr, [Device "device"; Int "partnum"; String "guid"], [];
+    style = RErr, [Device "device"; Int "partnum"; GUID "guid"], [];
     proc_nr = Some 392;
     optional = Some "gdisk";
+    tests = [
+      InitGPT, Always, TestLastFail (
+        [["part_set_gpt_type"; "/dev/sda"; "1"; "f"]]), [];
+      InitGPT, Always, TestResultString (
+        [["part_set_gpt_type"; "/dev/sda"; "1";
+          "01234567-89AB-CDEF-0123-456789ABCDEF"];
+         ["part_get_gpt_type"; "/dev/sda"; "1"]],
+        "01234567-89AB-CDEF-0123-456789ABCDEF"), [];
+    ];
     shortdesc = "set the type GUID of a GPT partition";
     longdesc = "\
 Set the type GUID of numbered GPT partition C<partnum> to C<guid>. Return an
-- 
1.8.3.1




More information about the Libguestfs mailing list