Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
New APIs: Add support for syslinux and extlinux (bootloaders).
This also adds tests of SYSLINUX and EXTLINUX which create bootable guests.
- Loading branch information
Showing
15 changed files
with
366 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -161,6 +161,7 @@ guestfsd_SOURCES = \ | |
| stubs.c \ | ||
| swap.c \ | ||
| sync.c \ | ||
| syslinux.c \ | ||
| tar.c \ | ||
| truncate.c \ | ||
| umask.c \ | ||
|
|
||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| /* libguestfs - the guestfsd daemon | ||
| * Copyright (C) 2013 Red Hat Inc. | ||
| * | ||
| * This program is free software; you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation; either version 2 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| */ | ||
|
|
||
| #include <config.h> | ||
|
|
||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
| #include <string.h> | ||
| #include <unistd.h> | ||
| #include <fcntl.h> | ||
|
|
||
| #include "daemon.h" | ||
| #include "actions.h" | ||
| #include "optgroups.h" | ||
|
|
||
| GUESTFSD_EXT_CMD(str_syslinux, syslinux); | ||
| GUESTFSD_EXT_CMD(str_extlinux, extlinux); | ||
|
|
||
| int | ||
| optgroup_syslinux_available (void) | ||
| { | ||
| return prog_exists (str_syslinux); | ||
| } | ||
|
|
||
| int | ||
| optgroup_extlinux_available (void) | ||
| { | ||
| return prog_exists (str_extlinux); | ||
| } | ||
|
|
||
| /* Takes optional arguments, consult optargs_bitmask. */ | ||
| int | ||
| do_syslinux (const char *device, const char *directory) | ||
| { | ||
| const size_t MAX_ARGS = 32; | ||
| const char *argv[MAX_ARGS]; | ||
| size_t i = 0; | ||
| CLEANUP_FREE char *err = NULL; | ||
| int r; | ||
|
|
||
| ADD_ARG (argv, i, str_syslinux); | ||
| ADD_ARG (argv, i, "--install"); | ||
| ADD_ARG (argv, i, "--force"); | ||
|
|
||
| if (optargs_bitmask & GUESTFS_SYSLINUX_DIRECTORY_BITMASK) { | ||
| ADD_ARG (argv, i, "--directory"); | ||
| ADD_ARG (argv, i, directory); | ||
| } | ||
|
|
||
| ADD_ARG (argv, i, device); | ||
| ADD_ARG (argv, i, NULL); | ||
|
|
||
| r = commandv (NULL, &err, argv); | ||
| if (r == -1) { | ||
| reply_with_error ("%s", err); | ||
| return -1; | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| int | ||
| do_extlinux (const char *directory) | ||
| { | ||
| CLEANUP_FREE char *buf = sysroot_path (directory); | ||
| CLEANUP_FREE char *err = NULL; | ||
| int r; | ||
|
|
||
| if (!buf) { | ||
| reply_with_perror ("malloc"); | ||
| return -1; | ||
| } | ||
|
|
||
| r = command (NULL, &err, str_extlinux, "--install", buf, NULL); | ||
| if (r == -1) { | ||
| reply_with_error ("%s: %s", directory, err); | ||
| return -1; | ||
| } | ||
|
|
||
| return 0; | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 398 | ||
| 400 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # libguestfs | ||
| # Copyright (C) 2013 Red Hat Inc. | ||
| # | ||
| # This program is free software; you can redistribute it and/or modify | ||
| # it under the terms of the GNU General Public License as published by | ||
| # the Free Software Foundation; either version 2 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with this program; if not, write to the Free Software | ||
| # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
|
|
||
| include $(top_srcdir)/subdir-rules.mk | ||
|
|
||
| TESTS = \ | ||
| test-syslinux.sh \ | ||
| test-extlinux.sh | ||
|
|
||
| TESTS_ENVIRONMENT = $(top_builddir)/run --test | ||
|
|
||
| EXTRA_DIST = \ | ||
| $(TESTS) \ | ||
| test-syslinux.pl | ||
|
|
||
| CLEANFILES = syslinux-guest.img extlinux-guest.img |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| The tests in this directory simply run SYSLINUX/EXTLINUX (if | ||
| available) to make sure they work. | ||
|
|
||
| However if you want, you can also try booting the resultant guests, | ||
| although this is not part of the test. | ||
|
|
||
| qemu-kvm -hda syslinux-guest.img | ||
| qemu-kvm -hda extlinux-guest.img | ||
|
|
||
| Note that there is just a kernel, no operating system, inside these | ||
| guests so the Linux kernel is expected to panic once it tries to find | ||
| an init process to run. (You could modify these tests to add an init | ||
| process if you wanted to). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #!/bin/sh | ||
| # libguestfs | ||
| # Copyright (C) 2013 Red Hat Inc. | ||
| # | ||
| # This program is free software; you can redistribute it and/or modify | ||
| # it under the terms of the GNU General Public License as published by | ||
| # the Free Software Foundation; either version 2 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with this program; if not, write to the Free Software | ||
| # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
|
|
||
| BOOTLOADER=extlinux ./test-syslinux.pl |
Oops, something went wrong.