diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2009-06-29 20:24:47 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2009-06-29 20:25:20 +0100 |
commit | da8ddb2745c3d53c36e3ad7f09836a4c27a4d3e6 (patch) | |
tree | 5555f9addd140af8cf2b40c9526d1b1837abdd7f | |
parent | 662617ae725c5e41c24128a037060419fbe4b026 (diff) | |
download | libguestfs-da8ddb2745c3d53c36e3ad7f09836a4c27a4d3e6.tar.gz libguestfs-da8ddb2745c3d53c36e3ad7f09836a4c27a4d3e6.tar.xz libguestfs-da8ddb2745c3d53c36e3ad7f09836a4c27a4d3e6.zip |
Generated code for the 'mkswap*' commands.
-rw-r--r-- | capitests/tests.c | 229 | ||||
-rw-r--r-- | daemon/actions.h | 3 | ||||
-rw-r--r-- | daemon/stubs.c | 85 | ||||
-rw-r--r-- | fish/cmds.c | 67 | ||||
-rw-r--r-- | fish/completion.c | 3 | ||||
-rw-r--r-- | guestfish-actions.pod | 18 | ||||
-rw-r--r-- | guestfs-actions.pod | 29 | ||||
-rw-r--r-- | haskell/Guestfs.hs | 41 | ||||
-rw-r--r-- | java/com/redhat/et/libguestfs/GuestFS.java | 51 | ||||
-rw-r--r-- | java/com_redhat_et_libguestfs_GuestFS.c | 57 | ||||
-rw-r--r-- | ocaml/guestfs.ml | 3 | ||||
-rw-r--r-- | ocaml/guestfs.mli | 9 | ||||
-rw-r--r-- | ocaml/guestfs_c_actions.c | 71 | ||||
-rw-r--r-- | perl/Guestfs.xs | 35 | ||||
-rw-r--r-- | perl/lib/Sys/Guestfs.pm | 12 | ||||
-rw-r--r-- | python/guestfs-py.c | 80 | ||||
-rw-r--r-- | python/guestfs.py | 15 | ||||
-rw-r--r-- | ruby/ext/guestfs/_guestfs.c | 82 | ||||
-rw-r--r-- | src/MAX_PROC_NR | 2 | ||||
-rw-r--r-- | src/guestfs-actions.c | 265 | ||||
-rw-r--r-- | src/guestfs-actions.h | 3 | ||||
-rw-r--r-- | src/guestfs_protocol.c | 34 | ||||
-rw-r--r-- | src/guestfs_protocol.h | 28 | ||||
-rw-r--r-- | src/guestfs_protocol.x | 17 |
24 files changed, 1235 insertions, 4 deletions
diff --git a/capitests/tests.c b/capitests/tests.c index 455c20e3..f1a450b0 100644 --- a/capitests/tests.c +++ b/capitests/tests.c @@ -156,6 +156,215 @@ static void no_test_warnings (void) fprintf (stderr, "warning: \"guestfs_mount_loop\" has no tests\n"); } +static int test_mkswap_U_0_skip (void) +{ + const char *str; + + str = getenv ("TEST_ONLY"); + if (str) + return strstr (str, "mkswap_U") == NULL; + str = getenv ("SKIP_TEST_MKSWAP_U_0"); + if (str && strcmp (str, "1") == 0) return 1; + str = getenv ("SKIP_TEST_MKSWAP_U"); + if (str && strcmp (str, "1") == 0) return 1; + return 0; +} + +static int test_mkswap_U_0 (void) +{ + if (test_mkswap_U_0_skip ()) { + printf ("%s skipped (reason: environment variable set)\n", "test_mkswap_U_0"); + return 0; + } + + /* InitNone|InitEmpty for test_mkswap_U_0 */ + { + char device[] = "/dev/sda"; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + /* TestRun for mkswap_U (0) */ + { + char device[] = "/dev/sda"; + char lines_0[] = ","; + char *lines[] = { + lines_0, + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, device, 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + char uuid[] = "a3a61220-882b-4f61-89f4-cf24dcc7297d"; + char device[] = "/dev/sda1"; + int r; + suppress_error = 0; + r = guestfs_mkswap_U (g, uuid, device); + if (r == -1) + return -1; + } + return 0; +} + +static int test_mkswap_L_0_skip (void) +{ + const char *str; + + str = getenv ("TEST_ONLY"); + if (str) + return strstr (str, "mkswap_L") == NULL; + str = getenv ("SKIP_TEST_MKSWAP_L_0"); + if (str && strcmp (str, "1") == 0) return 1; + str = getenv ("SKIP_TEST_MKSWAP_L"); + if (str && strcmp (str, "1") == 0) return 1; + return 0; +} + +static int test_mkswap_L_0 (void) +{ + if (test_mkswap_L_0_skip ()) { + printf ("%s skipped (reason: environment variable set)\n", "test_mkswap_L_0"); + return 0; + } + + /* InitNone|InitEmpty for test_mkswap_L_0 */ + { + char device[] = "/dev/sda"; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + /* TestRun for mkswap_L (0) */ + { + char device[] = "/dev/sda"; + char lines_0[] = ","; + char *lines[] = { + lines_0, + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, device, 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + char label[] = "hello"; + char device[] = "/dev/sda1"; + int r; + suppress_error = 0; + r = guestfs_mkswap_L (g, label, device); + if (r == -1) + return -1; + } + return 0; +} + +static int test_mkswap_0_skip (void) +{ + const char *str; + + str = getenv ("TEST_ONLY"); + if (str) + return strstr (str, "mkswap") == NULL; + str = getenv ("SKIP_TEST_MKSWAP_0"); + if (str && strcmp (str, "1") == 0) return 1; + str = getenv ("SKIP_TEST_MKSWAP"); + if (str && strcmp (str, "1") == 0) return 1; + return 0; +} + +static int test_mkswap_0 (void) +{ + if (test_mkswap_0_skip ()) { + printf ("%s skipped (reason: environment variable set)\n", "test_mkswap_0"); + return 0; + } + + /* InitNone|InitEmpty for test_mkswap_0 */ + { + char device[] = "/dev/sda"; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + /* TestRun for mkswap (0) */ + { + char device[] = "/dev/sda"; + char lines_0[] = ","; + char *lines[] = { + lines_0, + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, device, 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda1"; + int r; + suppress_error = 0; + r = guestfs_mkswap (g, device); + if (r == -1) + return -1; + } + return 0; +} + static int test_initrd_list_0_skip (void) { const char *str; @@ -18764,9 +18973,27 @@ int main (int argc, char *argv[]) /* Cancel previous alarm. */ alarm (0); - nr_tests = 166; + nr_tests = 169; test_num++; + printf ("%3d/%3d test_mkswap_U_0\n", test_num, nr_tests); + if (test_mkswap_U_0 () == -1) { + printf ("test_mkswap_U_0 FAILED\n"); + failed++; + } + test_num++; + printf ("%3d/%3d test_mkswap_L_0\n", test_num, nr_tests); + if (test_mkswap_L_0 () == -1) { + printf ("test_mkswap_L_0 FAILED\n"); + failed++; + } + test_num++; + printf ("%3d/%3d test_mkswap_0\n", test_num, nr_tests); + if (test_mkswap_0 () == -1) { + printf ("test_mkswap_0 FAILED\n"); + failed++; + } + test_num++; printf ("%3d/%3d test_initrd_list_0\n", test_num, nr_tests); if (test_initrd_list_0 () == -1) { printf ("test_initrd_list_0 FAILED\n"); diff --git a/daemon/actions.h b/daemon/actions.h index 1d412dcc..3f8b7a80 100644 --- a/daemon/actions.h +++ b/daemon/actions.h @@ -150,3 +150,6 @@ extern char *do_df_h (void); extern int64_t do_du (char *path); extern char **do_initrd_list (char *path); extern int do_mount_loop (char *file, char *mountpoint); +extern int do_mkswap (char *device); +extern int do_mkswap_L (char *label, char *device); +extern int do_mkswap_U (char *uuid, char *device); diff --git a/daemon/stubs.c b/daemon/stubs.c index 6d7cb0e7..48f16c28 100644 --- a/daemon/stubs.c +++ b/daemon/stubs.c @@ -3259,6 +3259,82 @@ done: xdr_free ((xdrproc_t) xdr_guestfs_mount_loop_args, (char *) &args); } +static void mkswap_stub (XDR *xdr_in) +{ + int r; + struct guestfs_mkswap_args args; + char *device; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_mkswap_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "mkswap"); + return; + } + device = args.device; + + r = do_mkswap (device); + if (r == -1) + /* do_mkswap has already called reply_with_error */ + goto done; + + reply (NULL, NULL); +done: + xdr_free ((xdrproc_t) xdr_guestfs_mkswap_args, (char *) &args); +} + +static void mkswap_L_stub (XDR *xdr_in) +{ + int r; + struct guestfs_mkswap_L_args args; + char *label; + char *device; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_mkswap_L_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "mkswap_L"); + return; + } + label = args.label; + device = args.device; + + r = do_mkswap_L (label, device); + if (r == -1) + /* do_mkswap_L has already called reply_with_error */ + goto done; + + reply (NULL, NULL); +done: + xdr_free ((xdrproc_t) xdr_guestfs_mkswap_L_args, (char *) &args); +} + +static void mkswap_U_stub (XDR *xdr_in) +{ + int r; + struct guestfs_mkswap_U_args args; + char *uuid; + char *device; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_mkswap_U_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "mkswap_U"); + return; + } + uuid = args.uuid; + device = args.device; + + r = do_mkswap_U (uuid, device); + if (r == -1) + /* do_mkswap_U has already called reply_with_error */ + goto done; + + reply (NULL, NULL); +done: + xdr_free ((xdrproc_t) xdr_guestfs_mkswap_U_args, (char *) &args); +} + void dispatch_incoming_message (XDR *xdr_in) { switch (proc_nr) { @@ -3649,6 +3725,15 @@ void dispatch_incoming_message (XDR *xdr_in) case GUESTFS_PROC_MOUNT_LOOP: mount_loop_stub (xdr_in); break; + case GUESTFS_PROC_MKSWAP: + mkswap_stub (xdr_in); + break; + case GUESTFS_PROC_MKSWAP_L: + mkswap_L_stub (xdr_in); + break; + case GUESTFS_PROC_MKSWAP_U: + mkswap_U_stub (xdr_in); + break; default: reply_with_error ("dispatch_incoming_message: unknown procedure number %d, set LIBGUESTFS_PATH to point to the matching libguestfs appliance directory", proc_nr); } diff --git a/fish/cmds.c b/fish/cmds.c index c9c05158..a23fe2d7 100644 --- a/fish/cmds.c +++ b/fish/cmds.c @@ -116,6 +116,9 @@ void list_commands (void) printf ("%-20s %s\n", "mkdir-p", "create a directory and parents"); printf ("%-20s %s\n", "mkdtemp", "create a temporary directory"); printf ("%-20s %s\n", "mkfs", "make a filesystem"); + printf ("%-20s %s\n", "mkswap", "create a swap partition"); + printf ("%-20s %s\n", "mkswap-L", "create a swap partition with a label"); + printf ("%-20s %s\n", "mkswap-U", "create a swap partition with an explicit UUID"); printf ("%-20s %s\n", "mount", "mount a guest disk at a position in the filesystem"); printf ("%-20s %s\n", "mount-loop", "mount a file using the loop device"); printf ("%-20s %s\n", "mount-options", "mount a guest disk with mount options"); @@ -636,6 +639,15 @@ void display_command (const char *cmd) if (strcasecmp (cmd, "mount_loop") == 0 || strcasecmp (cmd, "mount-loop") == 0) pod2text ("mount-loop - mount a file using the loop device", " mount-loop <file> <mountpoint>\n\nThis command lets you mount C<file> (a filesystem image\nin a file) on a mount point. It is entirely equivalent to\nthe command C<mount -o loop file mountpoint>."); else + if (strcasecmp (cmd, "mkswap") == 0) + pod2text ("mkswap - create a swap partition", " mkswap <device>\n\nCreate a swap partition on C<device>."); + else + if (strcasecmp (cmd, "mkswap_L") == 0 || strcasecmp (cmd, "mkswap-L") == 0) + pod2text ("mkswap-L - create a swap partition with a label", " mkswap-L <label> <device>\n\nCreate a swap partition on C<device> with label C<label>."); + else + if (strcasecmp (cmd, "mkswap_U") == 0 || strcasecmp (cmd, "mkswap-U") == 0) + pod2text ("mkswap-U - create a swap partition with an explicit UUID", " mkswap-U <uuid> <device>\n\nCreate a swap partition on C<device> with UUID C<uuid>."); + else display_builtin_command (cmd); } @@ -3123,6 +3135,52 @@ static int run_mount_loop (const char *cmd, int argc, char *argv[]) return r; } +static int run_mkswap (const char *cmd, int argc, char *argv[]) +{ + int r; + const char *device; + if (argc != 1) { + fprintf (stderr, "%s should have 1 parameter(s)\n", cmd); + fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd); + return -1; + } + device = argv[0]; + r = guestfs_mkswap (g, device); + return r; +} + +static int run_mkswap_L (const char *cmd, int argc, char *argv[]) +{ + int r; + const char *label; + const char *device; + if (argc != 2) { + fprintf (stderr, "%s should have 2 parameter(s)\n", cmd); + fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd); + return -1; + } + label = argv[0]; + device = argv[1]; + r = guestfs_mkswap_L (g, label, device); + return r; +} + +static int run_mkswap_U (const char *cmd, int argc, char *argv[]) +{ + int r; + const char *uuid; + const char *device; + if (argc != 2) { + fprintf (stderr, "%s should have 2 parameter(s)\n", cmd); + fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd); + return -1; + } + uuid = argv[0]; + device = argv[1]; + r = guestfs_mkswap_U (g, uuid, device); + return r; +} + int run_action (const char *cmd, int argc, char *argv[]) { if (strcasecmp (cmd, "launch") == 0 || strcasecmp (cmd, "run") == 0) @@ -3575,6 +3633,15 @@ int run_action (const char *cmd, int argc, char *argv[]) if (strcasecmp (cmd, "mount_loop") == 0 || strcasecmp (cmd, "mount-loop") == 0) return run_mount_loop (cmd, argc, argv); else + if (strcasecmp (cmd, "mkswap") == 0) + return run_mkswap (cmd, argc, argv); + else + if (strcasecmp (cmd, "mkswap_L") == 0 || strcasecmp (cmd, "mkswap-L") == 0) + return run_mkswap_L (cmd, argc, argv); + else + if (strcasecmp (cmd, "mkswap_U") == 0 || strcasecmp (cmd, "mkswap-U") == 0) + return run_mkswap_U (cmd, argc, argv); + else { fprintf (stderr, "%s: unknown command\n", cmd); return -1; diff --git a/fish/completion.c b/fish/completion.c index 2ddfb433..4a247e1a 100644 --- a/fish/completion.c +++ b/fish/completion.c @@ -196,6 +196,9 @@ static const char *const commands[] = { "du", "initrd-list", "mount-loop", + "mkswap", + "mkswap-L", + "mkswap-U", NULL }; diff --git a/guestfish-actions.pod b/guestfish-actions.pod index a3592ad4..99519fc5 100644 --- a/guestfish-actions.pod +++ b/guestfish-actions.pod @@ -1014,6 +1014,24 @@ This creates a filesystem on C<device> (usually a partition or LVM logical volume). The filesystem type is C<fstype>, for example C<ext3>. +=head2 mkswap + + mkswap device + +Create a swap partition on C<device>. + +=head2 mkswap-L + + mkswap-L label device + +Create a swap partition on C<device> with label C<label>. + +=head2 mkswap-U + + mkswap-U uuid device + +Create a swap partition on C<device> with UUID C<uuid>. + =head2 mount mount device mountpoint diff --git a/guestfs-actions.pod b/guestfs-actions.pod index 56949faa..aade37b9 100644 --- a/guestfs-actions.pod +++ b/guestfs-actions.pod @@ -1331,6 +1331,35 @@ example C<ext3>. This function returns 0 on success or -1 on error. +=head2 guestfs_mkswap + + int guestfs_mkswap (guestfs_h *handle, + const char *device); + +Create a swap partition on C<device>. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_mkswap_L + + int guestfs_mkswap_L (guestfs_h *handle, + const char *label, + const char *device); + +Create a swap partition on C<device> with label C<label>. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_mkswap_U + + int guestfs_mkswap_U (guestfs_h *handle, + const char *uuid, + const char *device); + +Create a swap partition on C<device> with UUID C<uuid>. + +This function returns 0 on success or -1 on error. + =head2 guestfs_mount int guestfs_mount (guestfs_h *handle, diff --git a/haskell/Guestfs.hs b/haskell/Guestfs.hs index 32e7aedd..adf416f1 100644 --- a/haskell/Guestfs.hs +++ b/haskell/Guestfs.hs @@ -121,7 +121,10 @@ module Guestfs ( wc_w, wc_c, du, - mount_loop + mount_loop, + mkswap, + mkswap_L, + mkswap_U ) where import Foreign import Foreign.C @@ -1348,3 +1351,39 @@ mount_loop h file mountpoint = do fail err else return () +foreign import ccall unsafe "guestfs_mkswap" c_mkswap + :: GuestfsP -> CString -> IO (CInt) + +mkswap :: GuestfsH -> String -> IO () +mkswap h device = do + r <- withCString device $ \device -> withForeignPtr h (\p -> c_mkswap p device) + if (r == -1) + then do + err <- last_error h + fail err + else return () + +foreign import ccall unsafe "guestfs_mkswap_L" c_mkswap_L + :: GuestfsP -> CString -> CString -> IO (CInt) + +mkswap_L :: GuestfsH -> String -> String -> IO () +mkswap_L h label device = do + r <- withCString label $ \label -> withCString device $ \device -> withForeignPtr h (\p -> c_mkswap_L p label device) + if (r == -1) + then do + err <- last_error h + fail err + else return () + +foreign import ccall unsafe "guestfs_mkswap_U" c_mkswap_U + :: GuestfsP -> CString -> CString -> IO (CInt) + +mkswap_U :: GuestfsH -> String -> String -> IO () +mkswap_U h uuid device = do + r <- withCString uuid $ \uuid -> withCString device $ \device -> withForeignPtr h (\p -> c_mkswap_U p uuid device) + if (r == -1) + then do + err <- last_error h + fail err + else return () + diff --git a/java/com/redhat/et/libguestfs/GuestFS.java b/java/com/redhat/et/libguestfs/GuestFS.java index f2901497..c5d4364a 100644 --- a/java/com/redhat/et/libguestfs/GuestFS.java +++ b/java/com/redhat/et/libguestfs/GuestFS.java @@ -3839,4 +3839,55 @@ public HashMap<String,String> test0rhashtableerr () private native void _mount_loop (long g, String file, String mountpoint) throws LibGuestFSException; + /** + * create a swap partition + * <p> + * Create a swap partition on "device". + * <p> + * @throws LibGuestFSException + */ + public void mkswap (String device) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("mkswap: handle is closed"); + _mkswap (g, device); + } + private native void _mkswap (long g, String device) + throws LibGuestFSException; + + /** + * create a swap partition with a label + * <p> + * Create a swap partition on "device" with label "label". + * <p> + * @throws LibGuestFSException + */ + public void mkswap_L (String label, String device) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("mkswap_L: handle is closed"); + _mkswap_L (g, label, device); + } + private native void _mkswap_L (long g, String label, String device) + throws LibGuestFSException; + + /** + * create a swap partition with an explicit UUID + * <p> + * Create a swap partition on "device" with UUID "uuid". + * <p> + * @throws LibGuestFSException + */ + public void mkswap_U (String uuid, String device) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("mkswap_U: handle is closed"); + _mkswap_U (g, uuid, device); + } + private native void _mkswap_U (long g, String uuid, String device) + throws LibGuestFSException; + } diff --git a/java/com_redhat_et_libguestfs_GuestFS.c b/java/com_redhat_et_libguestfs_GuestFS.c index a58b489a..43cad683 100644 --- a/java/com_redhat_et_libguestfs_GuestFS.c +++ b/java/com_redhat_et_libguestfs_GuestFS.c @@ -4442,3 +4442,60 @@ Java_com_redhat_et_libguestfs_GuestFS__1mount_1loop } } +JNIEXPORT void JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1mkswap + (JNIEnv *env, jobject obj, jlong jg, jstring jdevice) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + int r; + const char *device; + + device = (*env)->GetStringUTFChars (env, jdevice, NULL); + r = guestfs_mkswap (g, device); + (*env)->ReleaseStringUTFChars (env, jdevice, device); + if (r == -1) { + throw_exception (env, guestfs_last_error (g)); + return ; + } +} + +JNIEXPORT void JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1mkswap_1L + (JNIEnv *env, jobject obj, jlong jg, jstring jlabel, jstring jdevice) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + int r; + const char *label; + const char *device; + + label = (*env)->GetStringUTFChars (env, jlabel, NULL); + device = (*env)->GetStringUTFChars (env, jdevice, NULL); + r = guestfs_mkswap_L (g, label, device); + (*env)->ReleaseStringUTFChars (env, jlabel, label); + (*env)->ReleaseStringUTFChars (env, jdevice, device); + if (r == -1) { + throw_exception (env, guestfs_last_error (g)); + return ; + } +} + +JNIEXPORT void JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1mkswap_1U + (JNIEnv *env, jobject obj, jlong jg, jstring juuid, jstring jdevice) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + int r; + const char *uuid; + const char *device; + + uuid = (*env)->GetStringUTFChars (env, juuid, NULL); + device = (*env)->GetStringUTFChars (env, jdevice, NULL); + r = guestfs_mkswap_U (g, uuid, device); + (*env)->ReleaseStringUTFChars (env, juuid, uuid); + (*env)->ReleaseStringUTFChars (env, jdevice, device); + if (r == -1) { + throw_exception (env, guestfs_last_error (g)); + return ; + } +} + diff --git a/ocaml/guestfs.ml b/ocaml/guestfs.ml index d9b652b7..c64e2576 100644 --- a/ocaml/guestfs.ml +++ b/ocaml/guestfs.ml @@ -296,3 +296,6 @@ external df_h : t -> string = "ocaml_guestfs_df_h" external du : t -> string -> int64 = "ocaml_guestfs_du" external initrd_list : t -> string -> string array = "ocaml_guestfs_initrd_list" external mount_loop : t -> string -> string -> unit = "ocaml_guestfs_mount_loop" +external mkswap : t -> string -> unit = "ocaml_guestfs_mkswap" +external mkswap_L : t -> string -> string -> unit = "ocaml_guestfs_mkswap_L" +external mkswap_U : t -> string -> string -> unit = "ocaml_guestfs_mkswap_U" diff --git a/ocaml/guestfs.mli b/ocaml/guestfs.mli index 612d0022..dc09056b 100644 --- a/ocaml/guestfs.mli +++ b/ocaml/guestfs.mli @@ -667,3 +667,12 @@ val initrd_list : t -> string -> string array val mount_loop : t -> string -> string -> unit (** mount a file using the loop device *) +val mkswap : t -> string -> unit +(** create a swap partition *) + +val mkswap_L : t -> string -> string -> unit +(** create a swap partition with a label *) + +val mkswap_U : t -> string -> string -> unit +(** create a swap partition with an explicit UUID *) + diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c index 8b018f6e..3eedbda6 100644 --- a/ocaml/guestfs_c_actions.c +++ b/ocaml/guestfs_c_actions.c @@ -4661,3 +4661,74 @@ ocaml_guestfs_mount_loop (value gv, value filev, value mountpointv) CAMLreturn (rv); } +CAMLprim value +ocaml_guestfs_mkswap (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("mkswap: used handle after closing it"); + + const char *device = String_val (devicev); + int r; + + caml_enter_blocking_section (); + r = guestfs_mkswap (g, device); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "mkswap"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_mkswap_L (value gv, value labelv, value devicev) +{ + CAMLparam3 (gv, labelv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("mkswap_L: used handle after closing it"); + + const char *label = String_val (labelv); + const char *device = String_val (devicev); + int r; + + caml_enter_blocking_section (); + r = guestfs_mkswap_L (g, label, device); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "mkswap_L"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_mkswap_U (value gv, value uuidv, value devicev) +{ + CAMLparam3 (gv, uuidv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("mkswap_U: used handle after closing it"); + + const char *uuid = String_val (uuidv); + const char *device = String_val (devicev); + int r; + + caml_enter_blocking_section (); + r = guestfs_mkswap_U (g, uuid, device); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "mkswap_U"); + + rv = Val_unit; + CAMLreturn (rv); +} + diff --git a/perl/Guestfs.xs b/perl/Guestfs.xs index f19ea1a1..e1da744b 100644 --- a/perl/Guestfs.xs +++ b/perl/Guestfs.xs @@ -2843,3 +2843,38 @@ PREINIT: if (r == -1) croak ("mount_loop: %s", guestfs_last_error (g)); +void +mkswap (g, device) + guestfs_h *g; + char *device; +PREINIT: + int r; + PPCODE: + r = guestfs_mkswap (g, device); + if (r == -1) + croak ("mkswap: %s", guestfs_last_error (g)); + +void +mkswap_L (g, label, device) + guestfs_h *g; + char *label; + char *device; +PREINIT: + int r; + PPCODE: + r = guestfs_mkswap_L (g, label, device); + if (r == -1) + croak ("mkswap_L: %s", guestfs_last_error (g)); + +void +mkswap_U (g, uuid, device) + guestfs_h *g; + char *uuid; + char *device; +PREINIT: + int r; + PPCODE: + r = guestfs_mkswap_U (g, uuid, device); + if (r == -1) + croak ("mkswap_U: %s", guestfs_last_error (g)); + diff --git a/perl/lib/Sys/Guestfs.pm b/perl/lib/Sys/Guestfs.pm index f0eb6a0f..de16bd0f 100644 --- a/perl/lib/Sys/Guestfs.pm +++ b/perl/lib/Sys/Guestfs.pm @@ -943,6 +943,18 @@ This creates a filesystem on C<device> (usually a partition or LVM logical volume). The filesystem type is C<fstype>, for example C<ext3>. +=item $h->mkswap ($device); + +Create a swap partition on C<device>. + +=item $h->mkswap_L ($label, $device); + +Create a swap partition on C<device> with label C<label>. + +=item $h->mkswap_U ($uuid, $device); + +Create a swap partition on C<device> with UUID C<uuid>. + =item $h->mount ($device, $mountpoint); Mount a guest disk at a position in the filesystem. Block devices diff --git a/python/guestfs-py.c b/python/guestfs-py.c index 6a81349b..340beebe 100644 --- a/python/guestfs-py.c +++ b/python/guestfs-py.c @@ -4928,6 +4928,83 @@ py_guestfs_mount_loop (PyObject *self, PyObject *args) return py_r; } +static PyObject * +py_guestfs_mkswap (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + int r; + const char *device; + + if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_mkswap", + &py_g, &device)) + return NULL; + g = get_handle (py_g); + + r = guestfs_mkswap (g, device); + if (r == -1) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + Py_INCREF (Py_None); + py_r = Py_None; + return py_r; +} + +static PyObject * +py_guestfs_mkswap_L (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + int r; + const char *label; + const char *device; + + if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_mkswap_L", + &py_g, &label, &device)) + return NULL; + g = get_handle (py_g); + + r = guestfs_mkswap_L (g, label, device); + if (r == -1) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + Py_INCREF (Py_None); + py_r = Py_None; + return py_r; +} + +static PyObject * +py_guestfs_mkswap_U (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + int r; + const char *uuid; + const char *device; + + if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_mkswap_U", + &py_g, &uuid, &device)) + return NULL; + g = get_handle (py_g); + + r = guestfs_mkswap_U (g, uuid, device); + if (r == -1) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + Py_INCREF (Py_None); + py_r = Py_None; + return py_r; +} + static PyMethodDef methods[] = { { (char *) "create", py_guestfs_create, METH_VARARGS, NULL }, { (char *) "close", py_guestfs_close, METH_VARARGS, NULL }, @@ -5112,6 +5189,9 @@ static PyMethodDef methods[] = { { (char *) "du", py_guestfs_du, METH_VARARGS, NULL }, { (char *) "initrd_list", py_guestfs_initrd_list, METH_VARARGS, NULL }, { (char *) "mount_loop", py_guestfs_mount_loop, METH_VARARGS, NULL }, + { (char *) "mkswap", py_guestfs_mkswap, METH_VARARGS, NULL }, + { (char *) "mkswap_L", py_guestfs_mkswap_L, METH_VARARGS, NULL }, + { (char *) "mkswap_U", py_guestfs_mkswap_U, METH_VARARGS, NULL }, { NULL, NULL, 0, NULL } }; diff --git a/python/guestfs.py b/python/guestfs.py index 46b02a48..aa3572bf 100644 --- a/python/guestfs.py +++ b/python/guestfs.py @@ -1863,3 +1863,18 @@ class GuestFS: """ return libguestfsmod.mount_loop (self._o, file, mountpoint) + def mkswap (self, device): + u"""Create a swap partition on "device". + """ + return libguestfsmod.mkswap (self._o, device) + + def mkswap_L (self, label, device): + u"""Create a swap partition on "device" with label "label". + """ + return libguestfsmod.mkswap_L (self._o, label, device) + + def mkswap_U (self, uuid, device): + u"""Create a swap partition on "device" with UUID "uuid". + """ + return libguestfsmod.mkswap_U (self._o, uuid, device) + diff --git a/ruby/ext/guestfs/_guestfs.c b/ruby/ext/guestfs/_guestfs.c index 40654f9b..28f99687 100644 --- a/ruby/ext/guestfs/_guestfs.c +++ b/ruby/ext/guestfs/_guestfs.c @@ -4638,6 +4638,82 @@ static VALUE ruby_guestfs_mount_loop (VALUE gv, VALUE filev, VALUE mountpointv) return Qnil; } +static VALUE ruby_guestfs_mkswap (VALUE gv, VALUE devicev) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "mkswap"); + + Check_Type (devicev, T_STRING); + const char *device = StringValueCStr (devicev); + if (!device) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "device", "mkswap"); + + int r; + + r = guestfs_mkswap (g, device); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + +static VALUE ruby_guestfs_mkswap_L (VALUE gv, VALUE labelv, VALUE devicev) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "mkswap_L"); + + Check_Type (labelv, T_STRING); + const char *label = StringValueCStr (labelv); + if (!label) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "label", "mkswap_L"); + Check_Type (devicev, T_STRING); + const char *device = StringValueCStr (devicev); + if (!device) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "device", "mkswap_L"); + + int r; + + r = guestfs_mkswap_L (g, label, device); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + +static VALUE ruby_guestfs_mkswap_U (VALUE gv, VALUE uuidv, VALUE devicev) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "mkswap_U"); + + Check_Type (uuidv, T_STRING); + const char *uuid = StringValueCStr (uuidv); + if (!uuid) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "uuid", "mkswap_U"); + Check_Type (devicev, T_STRING); + const char *device = StringValueCStr (devicev); + if (!device) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "device", "mkswap_U"); + + int r; + + r = guestfs_mkswap_U (g, uuid, device); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + /* Initialize the module. */ void Init__guestfs () { @@ -5010,4 +5086,10 @@ void Init__guestfs () ruby_guestfs_initrd_list, 1); rb_define_method (c_guestfs, "mount_loop", ruby_guestfs_mount_loop, 2); + rb_define_method (c_guestfs, "mkswap", + ruby_guestfs_mkswap, 1); + rb_define_method (c_guestfs, "mkswap_L", + ruby_guestfs_mkswap_L, 2); + rb_define_method (c_guestfs, "mkswap_U", + ruby_guestfs_mkswap_U, 2); } diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR index b0d73241..94361d49 100644 --- a/src/MAX_PROC_NR +++ b/src/MAX_PROC_NR @@ -1 +1 @@ -129 +132 diff --git a/src/guestfs-actions.c b/src/guestfs-actions.c index 94a08629..e81245a0 100644 --- a/src/guestfs-actions.c +++ b/src/guestfs-actions.c @@ -11835,3 +11835,268 @@ int guestfs_mount_loop (guestfs_h *g, return 0; } +struct mkswap_ctx { + /* This flag is set by the callbacks, so we know we've done + * the callbacks as expected, and in the right sequence. + * 0 = not called, 1 = reply_cb called. + */ + int cb_sequence; + struct guestfs_message_header hdr; + struct guestfs_message_error err; +}; + +static void mkswap_reply_cb (guestfs_h *g, void *data, XDR *xdr) +{ + guestfs_main_loop *ml = guestfs_get_main_loop (g); + struct mkswap_ctx *ctx = (struct mkswap_ctx *) data; + + /* This should definitely not happen. */ + if (ctx->cb_sequence != 0) { + ctx->cb_sequence = 9999; + error (g, "%s: internal error: reply callback called twice", "guestfs_mkswap"); + return; + } + + ml->main_loop_quit (ml, g); + + if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) { + error (g, "%s: failed to parse reply header", "guestfs_mkswap"); + return; + } + if (ctx->hdr.status == GUESTFS_STATUS_ERROR) { + if (!xdr_guestfs_message_error (xdr, &ctx->err)) { + error (g, "%s: failed to parse reply error", "guestfs_mkswap"); + return; + } + goto done; + } + done: + ctx->cb_sequence = 1; +} + +int guestfs_mkswap (guestfs_h *g, + const char *device) +{ + struct guestfs_mkswap_args args; + struct mkswap_ctx ctx; + guestfs_main_loop *ml = guestfs_get_main_loop (g); + int serial; + + if (check_state (g, "guestfs_mkswap") == -1) return -1; + guestfs_set_busy (g); + + memset (&ctx, 0, sizeof ctx); + + args.device = (char *) device; + serial = guestfs__send_sync (g, GUESTFS_PROC_MKSWAP, + (xdrproc_t) xdr_guestfs_mkswap_args, (char *) &args); + if (serial == -1) { + guestfs_end_busy (g); + return -1; + } + + guestfs__switch_to_receiving (g); + ctx.cb_sequence = 0; + guestfs_set_reply_callback (g, mkswap_reply_cb, &ctx); + (void) ml->main_loop_run (ml, g); + guestfs_set_reply_callback (g, NULL, NULL); + if (ctx.cb_sequence != 1) { + error (g, "%s reply failed, see earlier error messages", "guestfs_mkswap"); + guestfs_end_busy (g); + return -1; + } + + if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MKSWAP, serial) == -1) { + guestfs_end_busy (g); + return -1; + } + + if (ctx.hdr.status == GUESTFS_STATUS_ERROR) { + error (g, "%s", ctx.err.error_message); + free (ctx.err.error_message); + guestfs_end_busy (g); + return -1; + } + + guestfs_end_busy (g); + return 0; +} + +struct mkswap_L_ctx { + /* This flag is set by the callbacks, so we know we've done + * the callbacks as expected, and in the right sequence. + * 0 = not called, 1 = reply_cb called. + */ + int cb_sequence; + struct guestfs_message_header hdr; + struct guestfs_message_error err; +}; + +static void mkswap_L_reply_cb (guestfs_h *g, void *data, XDR *xdr) +{ + guestfs_main_loop *ml = guestfs_get_main_loop (g); + struct mkswap_L_ctx *ctx = (struct mkswap_L_ctx *) data; + + /* This should definitely not happen. */ + if (ctx->cb_sequence != 0) { + ctx->cb_sequence = 9999; + error (g, "%s: internal error: reply callback called twice", "guestfs_mkswap_L"); + return; + } + + ml->main_loop_quit (ml, g); + + if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) { + error (g, "%s: failed to parse reply header", "guestfs_mkswap_L"); + return; + } + if (ctx->hdr.status == GUESTFS_STATUS_ERROR) { + if (!xdr_guestfs_message_error (xdr, &ctx->err)) { + error (g, "%s: failed to parse reply error", "guestfs_mkswap_L"); + return; + } + goto done; + } + done: + ctx->cb_sequence = 1; +} + +int guestfs_mkswap_L (guestfs_h *g, + const char *label, + const char *device) +{ + struct guestfs_mkswap_L_args args; + struct mkswap_L_ctx ctx; + guestfs_main_loop *ml = guestfs_get_main_loop (g); + int serial; + + if (check_state (g, "guestfs_mkswap_L") == -1) return -1; + guestfs_set_busy (g); + + memset (&ctx, 0, sizeof ctx); + + args.label = (char *) label; + args.device = (char *) device; + serial = guestfs__send_sync (g, GUESTFS_PROC_MKSWAP_L, + (xdrproc_t) xdr_guestfs_mkswap_L_args, (char *) &args); + if (serial == -1) { + guestfs_end_busy (g); + return -1; + } + + guestfs__switch_to_receiving (g); + ctx.cb_sequence = 0; + guestfs_set_reply_callback (g, mkswap_L_reply_cb, &ctx); + (void) ml->main_loop_run (ml, g); + guestfs_set_reply_callback (g, NULL, NULL); + if (ctx.cb_sequence != 1) { + error (g, "%s reply failed, see earlier error messages", "guestfs_mkswap_L"); + guestfs_end_busy (g); + return -1; + } + + if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MKSWAP_L, serial) == -1) { + guestfs_end_busy (g); + return -1; + } + + if (ctx.hdr.status == GUESTFS_STATUS_ERROR) { + error (g, "%s", ctx.err.error_message); + free (ctx.err.error_message); + guestfs_end_busy (g); + return -1; + } + + guestfs_end_busy (g); + return 0; +} + +struct mkswap_U_ctx { + /* This flag is set by the callbacks, so we know we've done + * the callbacks as expected, and in the right sequence. + * 0 = not called, 1 = reply_cb called. + */ + int cb_sequence; + struct guestfs_message_header hdr; + struct guestfs_message_error err; +}; + +static void mkswap_U_reply_cb (guestfs_h *g, void *data, XDR *xdr) +{ + guestfs_main_loop *ml = guestfs_get_main_loop (g); + struct mkswap_U_ctx *ctx = (struct mkswap_U_ctx *) data; + + /* This should definitely not happen. */ + if (ctx->cb_sequence != 0) { + ctx->cb_sequence = 9999; + error (g, "%s: internal error: reply callback called twice", "guestfs_mkswap_U"); + return; + } + + ml->main_loop_quit (ml, g); + + if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) { + error (g, "%s: failed to parse reply header", "guestfs_mkswap_U"); + return; + } + if (ctx->hdr.status == GUESTFS_STATUS_ERROR) { + if (!xdr_guestfs_message_error (xdr, &ctx->err)) { + error (g, "%s: failed to parse reply error", "guestfs_mkswap_U"); + return; + } + goto done; + } + done: + ctx->cb_sequence = 1; +} + +int guestfs_mkswap_U (guestfs_h *g, + const char *uuid, + const char *device) +{ + struct guestfs_mkswap_U_args args; + struct mkswap_U_ctx ctx; + guestfs_main_loop *ml = guestfs_get_main_loop (g); + int serial; + + if (check_state (g, "guestfs_mkswap_U") == -1) return -1; + guestfs_set_busy (g); + + memset (&ctx, 0, sizeof ctx); + + args.uuid = (char *) uuid; + args.device = (char *) device; + serial = guestfs__send_sync (g, GUESTFS_PROC_MKSWAP_U, + (xdrproc_t) xdr_guestfs_mkswap_U_args, (char *) &args); + if (serial == -1) { + guestfs_end_busy (g); + return -1; + } + + guestfs__switch_to_receiving (g); + ctx.cb_sequence = 0; + guestfs_set_reply_callback (g, mkswap_U_reply_cb, &ctx); + (void) ml->main_loop_run (ml, g); + guestfs_set_reply_callback (g, NULL, NULL); + if (ctx.cb_sequence != 1) { + error (g, "%s reply failed, see earlier error messages", "guestfs_mkswap_U"); + guestfs_end_busy (g); + return -1; + } + + if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MKSWAP_U, serial) == -1) { + guestfs_end_busy (g); + return -1; + } + + if (ctx.hdr.status == GUESTFS_STATUS_ERROR) { + error (g, "%s", ctx.err.error_message); + free (ctx.err.error_message); + guestfs_end_busy (g); + return -1; + } + + guestfs_end_busy (g); + return 0; +} + diff --git a/src/guestfs-actions.h b/src/guestfs-actions.h index c0002662..c6d2933c 100644 --- a/src/guestfs-actions.h +++ b/src/guestfs-actions.h @@ -200,3 +200,6 @@ extern char *guestfs_df_h (guestfs_h *handle); extern int64_t guestfs_du (guestfs_h *handle, const char *path); extern char **guestfs_initrd_list (guestfs_h *handle, const char *path); extern int guestfs_mount_loop (guestfs_h *handle, const char *file, const char *mountpoint); +extern int guestfs_mkswap (guestfs_h *handle, const char *device); +extern int guestfs_mkswap_L (guestfs_h *handle, const char *label, const char *device); +extern int guestfs_mkswap_U (guestfs_h *handle, const char *uuid, const char *device); diff --git a/src/guestfs_protocol.c b/src/guestfs_protocol.c index 9b12986c..37c74da4 100644 --- a/src/guestfs_protocol.c +++ b/src/guestfs_protocol.c @@ -2204,6 +2204,40 @@ xdr_guestfs_mount_loop_args (XDR *xdrs, guestfs_mount_loop_args *objp) } bool_t +xdr_guestfs_mkswap_args (XDR *xdrs, guestfs_mkswap_args *objp) +{ + register int32_t *buf; + + if (!xdr_string (xdrs, &objp->device, ~0)) + return FALSE; + return TRUE; +} + +bool_t +xdr_guestfs_mkswap_L_args (XDR *xdrs, guestfs_mkswap_L_args *objp) +{ + register int32_t *buf; + + if (!xdr_string (xdrs, &objp->label, ~0)) + return FALSE; + if (!xdr_string (xdrs, &objp->device, ~0)) + return FALSE; + return TRUE; +} + +bool_t +xdr_guestfs_mkswap_U_args (XDR *xdrs, guestfs_mkswap_U_args *objp) +{ + register int32_t *buf; + + if (!xdr_string (xdrs, &objp->uuid, ~0)) + return FALSE; + if (!xdr_string (xdrs, &objp->device, ~0)) + return FALSE; + return TRUE; +} + +bool_t xdr_guestfs_procedure (XDR *xdrs, guestfs_procedure *objp) { register int32_t *buf; diff --git a/src/guestfs_protocol.h b/src/guestfs_protocol.h index d127b884..7931bb59 100644 --- a/src/guestfs_protocol.h +++ b/src/guestfs_protocol.h @@ -1130,6 +1130,23 @@ struct guestfs_mount_loop_args { }; typedef struct guestfs_mount_loop_args guestfs_mount_loop_args; +struct guestfs_mkswap_args { + char *device; +}; +typedef struct guestfs_mkswap_args guestfs_mkswap_args; + +struct guestfs_mkswap_L_args { + char *label; + char *device; +}; +typedef struct guestfs_mkswap_L_args guestfs_mkswap_L_args; + +struct guestfs_mkswap_U_args { + char *uuid; + char *device; +}; +typedef struct guestfs_mkswap_U_args guestfs_mkswap_U_args; + enum guestfs_procedure { GUESTFS_PROC_MOUNT = 1, GUESTFS_PROC_SYNC = 2, @@ -1260,7 +1277,10 @@ enum guestfs_procedure { GUESTFS_PROC_DU = 127, GUESTFS_PROC_INITRD_LIST = 128, GUESTFS_PROC_MOUNT_LOOP = 129, - GUESTFS_PROC_NR_PROCS = 129 + 1, + GUESTFS_PROC_MKSWAP = 130, + GUESTFS_PROC_MKSWAP_L = 131, + GUESTFS_PROC_MKSWAP_U = 132, + GUESTFS_PROC_NR_PROCS = 132 + 1, }; typedef enum guestfs_procedure guestfs_procedure; #define GUESTFS_MESSAGE_MAX 4194304 @@ -1493,6 +1513,9 @@ extern bool_t xdr_guestfs_du_ret (XDR *, guestfs_du_ret*); extern bool_t xdr_guestfs_initrd_list_args (XDR *, guestfs_initrd_list_args*); extern bool_t xdr_guestfs_initrd_list_ret (XDR *, guestfs_initrd_list_ret*); extern bool_t xdr_guestfs_mount_loop_args (XDR *, guestfs_mount_loop_args*); +extern bool_t xdr_guestfs_mkswap_args (XDR *, guestfs_mkswap_args*); +extern bool_t xdr_guestfs_mkswap_L_args (XDR *, guestfs_mkswap_L_args*); +extern bool_t xdr_guestfs_mkswap_U_args (XDR *, guestfs_mkswap_U_args*); extern bool_t xdr_guestfs_procedure (XDR *, guestfs_procedure*); extern bool_t xdr_guestfs_message_direction (XDR *, guestfs_message_direction*); extern bool_t xdr_guestfs_message_status (XDR *, guestfs_message_status*); @@ -1684,6 +1707,9 @@ extern bool_t xdr_guestfs_du_ret (); extern bool_t xdr_guestfs_initrd_list_args (); extern bool_t xdr_guestfs_initrd_list_ret (); extern bool_t xdr_guestfs_mount_loop_args (); +extern bool_t xdr_guestfs_mkswap_args (); +extern bool_t xdr_guestfs_mkswap_L_args (); +extern bool_t xdr_guestfs_mkswap_U_args (); extern bool_t xdr_guestfs_procedure (); extern bool_t xdr_guestfs_message_direction (); extern bool_t xdr_guestfs_message_status (); diff --git a/src/guestfs_protocol.x b/src/guestfs_protocol.x index fdc67c15..55782842 100644 --- a/src/guestfs_protocol.x +++ b/src/guestfs_protocol.x @@ -863,6 +863,20 @@ struct guestfs_mount_loop_args { string mountpoint<>; }; +struct guestfs_mkswap_args { + string device<>; +}; + +struct guestfs_mkswap_L_args { + string label<>; + string device<>; +}; + +struct guestfs_mkswap_U_args { + string uuid<>; + string device<>; +}; + enum guestfs_procedure { GUESTFS_PROC_MOUNT = 1, GUESTFS_PROC_SYNC = 2, @@ -993,6 +1007,9 @@ enum guestfs_procedure { GUESTFS_PROC_DU = 127, GUESTFS_PROC_INITRD_LIST = 128, GUESTFS_PROC_MOUNT_LOOP = 129, + GUESTFS_PROC_MKSWAP = 130, + GUESTFS_PROC_MKSWAP_L = 131, + GUESTFS_PROC_MKSWAP_U = 132, GUESTFS_PROC_NR_PROCS }; |