Adventures in building libguestfs on non-x86 architectures for Debian
by Hilko Bengen
Hi,
things are progressing slowly, but I feel that eventually I'll be
getting there: supermin can be built on all Linux-based architectures
that are part of Debian/unstable[1] -- (except for sparc, but I'll
ignore that for now.) libguestfs on the other hand currently fails
launching the appliance (necessary for running tests) on everything but
x86 and mips.
Apparently, qemu-system-arm 2.0 as currently available through
Debian/unstable doesn't want to tell us anything about available devices
unless we specify a machine type. The patch below works around that
issue, but I haven't been able to run qemu-system-arm with a supermin
appliance on Debian's armhf porterbox so far: 100% CPU usage, no output
from the kernel.
For armel, there's no kernel with device tree blobs, so I think that I'll
need to use linux-image-versatile there or ignore armel altogether.
powerpc: qemu-system-ppc does not know about the "pseries" machine, I
have figured out that I need to use qemu-system-ppc64 for that. So far,
I haven't been able to manually boot a Supermin appliance using
qemu-system-ppc, either, though.
s390x does not seem to know about virtio-blk-pci.
Cheers,
-Hilko
[1] https://buildd.debian.org/status/package.php?p=supermin
[2] https://buildd.debian.org/status/package.php?p=libguestfs
diff --git a/src/launch-direct.c b/src/launch-direct.c
index 1460c56..2332368 100644
--- a/src/launch-direct.c
+++ b/src/launch-direct.c
@@ -1020,6 +1020,10 @@ test_qemu (guestfs_h *g, struct backend_direct_data *data)
guestfs___cmd_add_arg (cmd3, g->hv);
guestfs___cmd_add_arg (cmd3, "-display");
guestfs___cmd_add_arg (cmd3, "none");
+#ifdef MACHINE_TYPE
+ guestfs___cmd_add_arg (cmd3, "-M");
+ guestfs___cmd_add_arg (cmd3, MACHINE_TYPE);
+#endif
guestfs___cmd_add_arg (cmd3, "-machine");
guestfs___cmd_add_arg (cmd3, "accel=kvm:tcg");
guestfs___cmd_add_arg (cmd3, "-device");
10 years, 4 months
Labelling /etc/resolv.conf (rh#1089100)
by Pino Toscano
Hi,
I was investigating rh#1089100, which is about /etc/resolv.conf not
being properly SELinux-labelled.
Basically the problem is due to /etc/resolv.conf in the guest (so
available as /sysroot/etc/resolv.conf in the appliance) being moved when
executing shell commands (eg guestfs_sh) by the daemon.
This operation involves:
a) moving away guest's /etc/resolv.conf
b) replacing it with the /etc/resolv.conf in the appliance
c) executing the actual shell command
d) moving the guest's /etc/resolv.conf back
... but only if the network is enabled (which is by default).
So far all the ideas I found (to fix the label of /etc/resolv.conf when
--selinux-relabel is asked) were:
1) get the security.selinux xattr before (a), and restore it after (d).
This seems to not have worked at all, at least for me: the read xattr
is "unlabeled", which SELinux obviously refuses later; hence I
discarded it
2) closing the guestfs handle, open a new one with the network disabled
and do the relabel.
This works for me, but has the drawback to slow the process if the
relabel is asked and the network is enabled, as closing+opening an
appliance could not be that fast
3) allow to switch the network on/off also when the appliance is up.
This would require to actually turn on/off the networking at
runtime, which surely cannot be done with the direct backend and most
probably neither with libvirt (but I didn't research hard on this).
Is anything obvious I'm missing? Can I go with solution #2?
--
Pino Toscano
10 years, 6 months
[PATCH 2/2] Fix handling of passwords in URLs
by Pino Toscano
So far, passwords in URLs (eg http://user:password@host..) have been
handled as part of the username, and thus passing
add-drive path username:username:password ...
instead of
add-drive path username:username secret:password ...
Fix the parsing of URLs to handle passwords as separate elements,
properly passing it as "secret" parameter for add-drive, and properly
readd it when building URLs in the direct backend.
Furthmore, to keep curl- and ssh-based qemu drivers working with
authenticated resources, make sure they can accept secrets.
Reported in comment #1 of RHBZ#1092583.
---
customize/customize_main.ml | 5 +++--
fish/options.c | 6 ++++++
fish/options.h | 1 +
fish/uri.c | 26 ++++++++++++++++++++++----
fish/uri.h | 1 +
mllib/uRI.ml | 1 +
mllib/uRI.mli | 1 +
mllib/uri-c.c | 13 ++++++++++++-
resize/resize.ml | 5 +++--
src/drives.c | 10 ----------
src/launch-direct.c | 34 +++++++++++++++++++++++-----------
sysprep/main.ml | 5 +++--
12 files changed, 76 insertions(+), 32 deletions(-)
diff --git a/customize/customize_main.ml b/customize/customize_main.ml
index fb38336..00d5bae 100644
--- a/customize/customize_main.ml
+++ b/customize/customize_main.ml
@@ -157,11 +157,12 @@ read the man page virt-customize(1).
List.iter (
fun (uri, format) ->
let { URI.path = path; protocol = protocol;
- server = server; username = username } = uri in
+ server = server; username = username;
+ password = password } = uri in
let discard = if readonly then None else Some "besteffort" in
g#add_drive
~readonly ?discard
- ?format ~protocol ?server ?username
+ ?format ~protocol ?server ?username ?secret:password
path
) files
in
diff --git a/fish/options.c b/fish/options.c
index 80b71ec..5e6eb73 100644
--- a/fish/options.c
+++ b/fish/options.c
@@ -67,6 +67,7 @@ option_a (const char *arg, const char *format, struct drv **drvsp)
drv->uri.protocol = uri.protocol;
drv->uri.server = uri.server;
drv->uri.username = uri.username;
+ drv->uri.password = uri.password;
drv->uri.format = format;
drv->uri.orig_uri = arg;
}
@@ -167,6 +168,10 @@ add_drives_handle (guestfs_h *g, struct drv *drv, char next_drive)
ad_optargs.bitmask |= GUESTFS_ADD_DRIVE_OPTS_USERNAME_BITMASK;
ad_optargs.username = drv->uri.username;
}
+ if (drv->uri.password) {
+ ad_optargs.bitmask |= GUESTFS_ADD_DRIVE_OPTS_SECRET_BITMASK;
+ ad_optargs.secret = drv->uri.password;
+ }
r = guestfs_add_drive_opts_argv (g, drv->uri.path, &ad_optargs);
if (r == -1)
@@ -290,6 +295,7 @@ free_drives (struct drv *drv)
free (drv->uri.protocol);
guestfs___free_string_list (drv->uri.server);
free (drv->uri.username);
+ free (drv->uri.password);
break;
case drv_d:
/* d.filename is optarg, don't free it */
diff --git a/fish/options.h b/fish/options.h
index dbf9163..639b1fe 100644
--- a/fish/options.h
+++ b/fish/options.h
@@ -68,6 +68,7 @@ struct drv {
char *protocol; /* protocol (eg. "nbd") */
char **server; /* server(s) - can be NULL */
char *username; /* username - can be NULL */
+ char *password; /* password - can be NULL */
const char *format; /* format (NULL == autodetect) */
const char *orig_uri; /* original URI (for error messages etc.) */
} uri;
diff --git a/fish/uri.c b/fish/uri.c
index 95f8cf8..f45c907 100644
--- a/fish/uri.c
+++ b/fish/uri.c
@@ -34,7 +34,7 @@
#include "uri.h"
static int is_uri (const char *arg);
-static int parse (const char *arg, char **path_ret, char **protocol_ret, char ***server_ret, char **username_ret);
+static int parse (const char *arg, char **path_ret, char **protocol_ret, char ***server_ret, char **username_ret, char **password_ret);
static char *query_get (xmlURIPtr uri, const char *search_name);
static int make_server (xmlURIPtr uri, const char *socket, char ***ret);
@@ -45,10 +45,11 @@ parse_uri (const char *arg, struct uri *uri_ret)
char *protocol = NULL;
char **server = NULL;
char *username = NULL;
+ char *password = NULL;
/* Does it look like a URI? */
if (is_uri (arg)) {
- if (parse (arg, &path, &protocol, &server, &username) == -1)
+ if (parse (arg, &path, &protocol, &server, &username, &password) == -1)
return -1;
}
else {
@@ -70,6 +71,7 @@ parse_uri (const char *arg, struct uri *uri_ret)
uri_ret->protocol = protocol;
uri_ret->server = server;
uri_ret->username = username;
+ uri_ret->password = password;
return 0;
}
@@ -99,7 +101,7 @@ is_uri (const char *arg)
static int
parse (const char *arg, char **path_ret, char **protocol_ret,
- char ***server_ret, char **username_ret)
+ char ***server_ret, char **username_ret, char **password_ret)
{
CLEANUP_XMLFREEURI xmlURIPtr uri = NULL;
CLEANUP_FREE char *socket = NULL;
@@ -150,16 +152,31 @@ parse (const char *arg, char **path_ret, char **protocol_ret,
return -1;
}
+ *password_ret = NULL;
+ *username_ret = NULL;
if (uri->user && STRNEQ (uri->user, "")) {
+ char *p = strchr (uri->user, ':');
+ if (p != NULL) {
+ if (STRNEQ (p+1, "")) {
+ *password_ret = strdup (p+1);
+ if (*password_ret == NULL) {
+ perror ("strdup: password");
+ free (*protocol_ret);
+ guestfs___free_string_list (*server_ret);
+ return -1;
+ }
+ }
+ *p = '\0';
+ }
*username_ret = strdup (uri->user);
if (*username_ret == NULL) {
perror ("strdup: username");
+ free (*password_ret);
free (*protocol_ret);
guestfs___free_string_list (*server_ret);
return -1;
}
}
- else *username_ret = NULL;
/* We may have to adjust the path depending on the protocol. For
* example ceph/rbd URIs look like rbd:///pool/disk, but the
@@ -180,6 +197,7 @@ parse (const char *arg, char **path_ret, char **protocol_ret,
free (*protocol_ret);
guestfs___free_string_list (*server_ret);
free (*username_ret);
+ free (*password_ret);
return -1;
}
diff --git a/fish/uri.h b/fish/uri.h
index 420d20c..9202a70 100644
--- a/fish/uri.h
+++ b/fish/uri.h
@@ -26,6 +26,7 @@ struct uri {
char *protocol; /* protocol (eg. "file", "nbd") */
char **server; /* server(s) - can be NULL */
char *username; /* username - can be NULL */
+ char *password; /* password - can be NULL */
};
/* Parse the '-a' option parameter 'arg', and place the result in
diff --git a/mllib/uRI.ml b/mllib/uRI.ml
index 272f339..d4f7522 100644
--- a/mllib/uRI.ml
+++ b/mllib/uRI.ml
@@ -21,6 +21,7 @@ type uri = {
protocol : string;
server : string array option;
username : string option;
+ password : string option;
}
external parse_uri : string -> uri = "virt_resize_parse_uri"
diff --git a/mllib/uRI.mli b/mllib/uRI.mli
index efd39dd..0692f95 100644
--- a/mllib/uRI.mli
+++ b/mllib/uRI.mli
@@ -23,6 +23,7 @@ type uri = {
protocol : string; (** protocol, eg. [file], [nbd] *)
server : string array option; (** list of servers *)
username : string option; (** username *)
+ password : string option; (** password *)
}
val parse_uri : string -> uri
diff --git a/mllib/uri-c.c b/mllib/uri-c.c
index 1ae7350..2ce4021 100644
--- a/mllib/uri-c.c
+++ b/mllib/uri-c.c
@@ -47,7 +47,7 @@ virt_resize_parse_uri (value argv /* arg value, not an array! */)
caml_invalid_argument ("URI.parse_uri");
/* Convert the struct into an OCaml tuple. */
- rv = caml_alloc_tuple (4);
+ rv = caml_alloc_tuple (5);
/* path : string */
sv = caml_copy_string (uri.path);
@@ -81,5 +81,16 @@ virt_resize_parse_uri (value argv /* arg value, not an array! */)
ov = Val_int (0);
Store_field (rv, 3, ov);
+ /* password : string option */
+ if (uri.password) {
+ sv = caml_copy_string (uri.password);
+ free (uri.password);
+ ov = caml_alloc (1, 0);
+ Store_field (ov, 0, sv);
+ }
+ else
+ ov = Val_int (0);
+ Store_field (rv, 4, ov);
+
CAMLreturn (rv);
}
diff --git a/resize/resize.ml b/resize/resize.ml
index c1794ed..c6b6c9e 100644
--- a/resize/resize.ml
+++ b/resize/resize.ml
@@ -322,8 +322,9 @@ read the man page virt-resize(1).
let g = new G.guestfs () in
if debug then g#set_trace true;
let _, { URI.path = path; protocol = protocol;
- server = server; username = username } = infile in
- g#add_drive ?format ~readonly:true ~protocol ?server ?username path;
+ server = server; username = username;
+ password = password } = infile in
+ g#add_drive ?format ~readonly:true ~protocol ?server ?username ?secret:password path;
(* The output disk is being created, so use cache=unsafe here. *)
g#add_drive ?format:output_format ~readonly:false ~cachemode:"unsafe"
outfile;
diff --git a/src/drives.c b/src/drives.c
index 57c2471..4bd8328 100644
--- a/src/drives.c
+++ b/src/drives.c
@@ -200,11 +200,6 @@ static struct drive *
create_drive_curl (guestfs_h *g,
const struct drive_create_data *data)
{
- if (data->secret != NULL) {
- error (g, _("curl: you cannot specify a secret with this protocol"));
- return NULL;
- }
-
if (data->nr_servers != 1) {
error (g, _("curl: you must specify exactly one server"));
return NULL;
@@ -371,11 +366,6 @@ static struct drive *
create_drive_ssh (guestfs_h *g,
const struct drive_create_data *data)
{
- if (data->secret != NULL) {
- error (g, _("ssh: you cannot specify a secret with this protocol"));
- return NULL;
- }
-
if (data->nr_servers != 1) {
error (g, _("ssh: you must specify exactly one server"));
return NULL;
diff --git a/src/launch-direct.c b/src/launch-direct.c
index bb06c9e..96ae180 100644
--- a/src/launch-direct.c
+++ b/src/launch-direct.c
@@ -1207,12 +1207,14 @@ qemu_escape_param (guestfs_h *g, const char *param)
static char *
make_uri (guestfs_h *g, const char *scheme, const char *user,
+ const char *password,
struct drive_server *server, const char *path)
{
xmlURI uri = { .scheme = (char *) scheme,
.user = (char *) user };
CLEANUP_FREE char *query = NULL;
CLEANUP_FREE char *pathslash = NULL;
+ CLEANUP_FREE char *userauth = NULL;
/* Need to add a leading '/' to URI paths since xmlSaveUri doesn't. */
if (path[0] != '/') {
@@ -1222,6 +1224,13 @@ make_uri (guestfs_h *g, const char *scheme, const char *user,
else
uri.path = (char *) path;
+ /* Rebuild user:password. */
+ if (user != NULL && password != NULL) {
+ /* Keep the string in an own variable so it can be freed automatically. */
+ userauth = safe_asprintf (g, "%s:%s", user, password);
+ uri.user = userauth;
+ }
+
switch (server->transport) {
case drive_transport_none:
case drive_transport_tcp:
@@ -1267,34 +1276,37 @@ guestfs___drive_source_qemu_param (guestfs_h *g, const struct drive_source *src)
return path;
case drive_protocol_ftp:
- return make_uri (g, "ftp", src->username,
+ return make_uri (g, "ftp", src->username, src->secret,
&src->servers[0], src->u.exportname);
case drive_protocol_ftps:
- return make_uri (g, "ftps", src->username,
+ return make_uri (g, "ftps", src->username, src->secret,
&src->servers[0], src->u.exportname);
case drive_protocol_gluster:
switch (src->servers[0].transport) {
case drive_transport_none:
- return make_uri (g, "gluster", NULL, &src->servers[0], src->u.exportname);
+ return make_uri (g, "gluster", NULL, NULL,
+ &src->servers[0], src->u.exportname);
case drive_transport_tcp:
- return make_uri (g, "gluster+tcp",
- NULL, &src->servers[0], src->u.exportname);
+ return make_uri (g, "gluster+tcp", NULL, NULL,
+ &src->servers[0], src->u.exportname);
case drive_transport_unix:
- return make_uri (g, "gluster+unix", NULL, &src->servers[0], NULL);
+ return make_uri (g, "gluster+unix", NULL, NULL,
+ &src->servers[0], NULL);
}
case drive_protocol_http:
- return make_uri (g, "http", src->username,
+ return make_uri (g, "http", src->username, src->secret,
&src->servers[0], src->u.exportname);
case drive_protocol_https:
- return make_uri (g, "https", src->username,
+ return make_uri (g, "https", src->username, src->secret,
&src->servers[0], src->u.exportname);
case drive_protocol_iscsi:
- return make_uri (g, "iscsi", NULL, &src->servers[0], src->u.exportname);
+ return make_uri (g, "iscsi", NULL, NULL,
+ &src->servers[0], src->u.exportname);
case drive_protocol_nbd: {
CLEANUP_FREE char *p = NULL;
@@ -1380,11 +1392,11 @@ guestfs___drive_source_qemu_param (guestfs_h *g, const struct drive_source *src)
src->u.exportname);
case drive_protocol_ssh:
- return make_uri (g, "ssh", src->username,
+ return make_uri (g, "ssh", src->username, src->secret,
&src->servers[0], src->u.exportname);
case drive_protocol_tftp:
- return make_uri (g, "tftp", src->username,
+ return make_uri (g, "tftp", src->username, src->secret,
&src->servers[0], src->u.exportname);
}
diff --git a/sysprep/main.ml b/sysprep/main.ml
index 71abfa7..37e4dc8 100644
--- a/sysprep/main.ml
+++ b/sysprep/main.ml
@@ -203,11 +203,12 @@ read the man page virt-sysprep(1).
List.iter (
fun (uri, format) ->
let { URI.path = path; protocol = protocol;
- server = server; username = username } = uri in
+ server = server; username = username;
+ password = password } = uri in
let discard = if readonly then None else Some "besteffort" in
g#add_drive
~readonly ?discard
- ?format ~protocol ?server ?username
+ ?format ~protocol ?server ?username ?secret:password
path
) files
in
--
1.9.0
10 years, 6 months
[PATCH] daemon: xattr: factorize do_getxattr and do_lgetxattr
by Pino Toscano
Move all the common code to a new _getxattr function, much like done for
other xattrs operations.
Mostly code motion, no functional changes.
---
daemon/xattr.c | 54 +++++++++++-------------------------------------------
1 file changed, 11 insertions(+), 43 deletions(-)
diff --git a/daemon/xattr.c b/daemon/xattr.c
index abed5ff..d8ad59a 100644
--- a/daemon/xattr.c
+++ b/daemon/xattr.c
@@ -55,6 +55,7 @@ static guestfs_int_xattr_list *getxattrs (const char *path, ssize_t (*listxattr)
static int _setxattr (const char *xattr, const char *val, int vallen, const char *path, int (*setxattr) (const char *path, const char *name, const void *value, size_t size, int flags));
static int _removexattr (const char *xattr, const char *path, int (*removexattr) (const char *path, const char *name));
static char *_listxattrs (const char *path, ssize_t (*listxattr) (const char *path, char *list, size_t size), ssize_t *size);
+static char *_getxattr (const char *name, const char *path, ssize_t (*getxattr) (const char *path, const char *name, void *value, size_t size), size_t *size_r);
guestfs_int_xattr_list *
do_getxattrs (const char *path)
@@ -448,6 +449,15 @@ do_internal_lxattrlist (const char *path, char *const *names)
char *
do_getxattr (const char *path, const char *name, size_t *size_r)
{
+ return _getxattr (name, path, getxattr, size_r);
+}
+
+static char *
+_getxattr (const char *name, const char *path,
+ ssize_t (*getxattr) (const char *path, const char *name,
+ void *value, size_t size),
+ size_t *size_r)
+{
ssize_t r;
char *buf;
size_t len;
@@ -496,49 +506,7 @@ do_getxattr (const char *path, const char *name, size_t *size_r)
char *
do_lgetxattr (const char *path, const char *name, size_t *size_r)
{
- ssize_t r;
- char *buf;
- size_t len;
-
- CHROOT_IN;
- r = lgetxattr (path, name, NULL, 0);
- CHROOT_OUT;
- if (r == -1) {
- reply_with_perror ("lgetxattr");
- return NULL;
- }
-
- len = r;
-
- if (len > XATTR_SIZE_MAX) {
- reply_with_error ("extended attribute is too large");
- return NULL;
- }
-
- buf = malloc (len);
- if (buf == NULL) {
- reply_with_perror ("malloc");
- return NULL;
- }
-
- CHROOT_IN;
- r = lgetxattr (path, name, buf, len);
- CHROOT_OUT;
- if (r == -1) {
- reply_with_perror ("lgetxattr");
- free (buf);
- return NULL;
- }
-
- if (len != (size_t) r) {
- reply_with_error ("lgetxattr: unexpected size (%zu/%zd)", len, r);
- free (buf);
- return NULL;
- }
-
- /* Must set size_r last thing before returning. */
- *size_r = len;
- return buf; /* caller frees */
+ return _getxattr (name, path, lgetxattr, size_r);
}
int
--
1.9.0
10 years, 6 months
[supermin] Be smarter about finding suitable kernel images
by Hilko Bengen
---
src/kernel.ml | 43 ++++++++++++++++++++++++++++---------------
1 file changed, 28 insertions(+), 15 deletions(-)
diff --git a/src/kernel.ml b/src/kernel.ml
index ed5aea3..436b1b0 100644
--- a/src/kernel.ml
+++ b/src/kernel.ml
@@ -23,6 +23,19 @@ open Utils
open Ext2fs
open Fnmatch
+let patt_of_cpu host_cpu =
+ let models =
+ match host_cpu with
+ | "mips" | "mips64" -> [host_cpu; "*-malta"]
+ | "ppc" | "powerpc" -> ["ppc"; "powerpc"]
+ | "sparc" | "sparc64" -> ["sparc"; "sparc64"]
+ | "amd64" | "x86_64" -> ["amd64"; "x86_64"]
+ | _ when host_cpu.[0] = 'i' && host_cpu.[2] = '8' && host_cpu.[3] = '6' -> ["?86"]
+ | _ when String.sub host_cpu 0 5 = "armv7" -> ["armmp"]
+ | _ -> [host_cpu]
+ in
+ List.map (fun model -> sprintf "vmlinu?-*-%s" model) models
+
let rec build_kernel debug host_cpu dtb_wildcard copy_kernel kernel dtb =
(* Locate the kernel. *)
let kernel_name, kernel_version =
@@ -59,9 +72,6 @@ and find_kernel debug host_cpu copy_kernel kernel =
let kernel_name = Filename.basename kernel_env in
kernel_env, kernel_name, kernel_version
with Not_found ->
- let is_x86 =
- String.length host_cpu = 4 &&
- host_cpu.[0] = 'i' && host_cpu.[2] = '8' && host_cpu.[3] = '6' in
let is_arm =
String.length host_cpu >= 3 &&
host_cpu.[0] = 'a' && host_cpu.[1] = 'r' && host_cpu.[2] = 'm' in
@@ -70,18 +80,16 @@ and find_kernel debug host_cpu copy_kernel kernel =
let all_files = Array.to_list all_files in
(* In original: ls -1dvr /boot/vmlinuz-*.$arch* 2>/dev/null | grep -v xen *)
- let patt =
- if is_x86 then "vmlinuz-*.i?86*"
- else "vmlinuz-*." ^ host_cpu ^ "*" in
- let files = kernel_filter patt is_arm all_files in
+ let patterns = patt_of_cpu host_cpu in
+ let files = kernel_filter patterns is_arm all_files in
let files =
if files <> [] then files
else
(* In original: ls -1dvr /boot/vmlinuz-* 2>/dev/null | grep -v xen *)
- kernel_filter "vmlinuz-*" is_arm all_files in
+ kernel_filter ["vmlinu?-*"] is_arm all_files in
- if files = [] then no_kernels ();
+ if files = [] then no_kernels (host_cpu);
let files = List.sort (fun a b -> compare_version b a) files in
let kernel_name = List.hd files in
@@ -95,10 +103,13 @@ and find_kernel debug host_cpu copy_kernel kernel =
copy_or_symlink_file copy_kernel kernel_file kernel;
kernel_name, kernel_version
-and kernel_filter patt is_arm all_files =
+and kernel_filter patterns is_arm all_files =
let files =
List.filter
- (fun filename -> fnmatch patt filename [FNM_NOESCAPE]) all_files in
+ (fun filename ->
+ List.exists
+ (fun patt -> fnmatch patt filename [FNM_NOESCAPE]) patterns
+ ) all_files in
let files =
List.filter (fun filename -> find filename "xen" = -1) files in
let files =
@@ -110,15 +121,16 @@ and kernel_filter patt is_arm all_files =
) in
List.filter (fun filename -> has_modpath filename) files
-and no_kernels () =
+and no_kernels (host_cpu) =
eprintf "\
-supermin: failed to find a suitable kernel.
+supermin: failed to find a suitable kernel (host_cpu=%s).
I looked for kernels in /boot and modules in /lib/modules.
If this is a Xen guest, and you only have Xen domU kernels
installed, try installing a fullvirt kernel (only for
-supermin use, you shouldn't boot the Xen guest with it).\n";
+supermin use, you shouldn't boot the Xen guest with it).\n"
+ host_cpu;
exit 1
and find_dtb debug copy_kernel kernel_name wildcard dtb =
@@ -200,7 +212,8 @@ and has_modpath kernel_name =
| Not_found -> false
and get_kernel_version kernel_name =
- if string_prefix "vmlinuz-" kernel_name then (
+ if (string_prefix "vmlinuz-" kernel_name) ||
+ (string_prefix "vmlinux-" kernel_name) then (
let kv = String.sub kernel_name 8 (String.length kernel_name - 8) in
if modules_dep_exists kv then kv
else get_kernel_version_from_name kernel_name
--
2.0.0.rc0
10 years, 7 months
[PATCH] virt-v2v: Catch invalid initrd path
by Mike Latimer
In some cases (specifically, SUSE grub2 environments) it is possible to
fail to update the block entries in device.map. In turn, this causes an
invalid path to be returned in perl-Bootloader code, which causes the
conversion to fail with the following message:
is_file_opts: is_file: is_file_stub: path must start with a / character
This patch prevents the problem by adding device.map (for /boot/grub and
/boot/grub2) to the list of configurations to remap, then adds a check
to ensure invalid paths are not passed to is_file_opts.
Note - This is for the existing (perl version) of virt-v2v.
---
lib/Sys/VirtConvert/Converter/Linux.pm | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/lib/Sys/VirtConvert/Converter/Linux.pm b/lib/Sys/VirtConvert/Converter/Linux.pm
index e8463bc..b673120 100644
--- a/lib/Sys/VirtConvert/Converter/Linux.pm
+++ b/lib/Sys/VirtConvert/Converter/Linux.pm
@@ -56,7 +56,10 @@ sub get_initrd
if (defined($initrd)) {
# If the initrd starts with (hdX,X), remove it.
$initrd =~ s/^\(hd.*\)//;
- return $initrd if ($g->is_file_opts($initrd, followsymlinks=>1));
+ # Catch invalid paths by ensuring first character is '/'
+ if ($initrd =~ /^\//) {
+ return $initrd if $g->is_file_opts($initrd, followsymlinks=>1);
+ }
}
}
@@ -2672,13 +2675,13 @@ sub _remap_block_devices
# Add standard configuration files to the checklist
push (@checklist, '/files/etc/fstab/*/spec');
+ push (@checklist, '/files/boot/*/device.map/*'.
+ '[label() != "#comment"]');
# Add grub or grub2 files to the checklist
if (defined($grub->{grub_conf})) {
push (@checklist, "/files$grub->{grub_conf}/*/kernel/root");
push (@checklist, "/files$grub->{grub_conf}/*/kernel/resume");
- push (@checklist, '/files/boot/grub/device.map/*'.
- '[label() != "#comment"]');
}
elsif (defined($grub->{cfg})) {
push (@checklist, '/files/etc/sysconfig/grub/GRUB_CMDLINE_LINUX');
--
1.8.4.5
10 years, 7 months
Root btrfs partition listed twice?
by Mike Latimer
Hi,
I know btrfs complicates filesystem lists due to the use of subvolumes.
However, I just noticed that the root partition itself ends up being listed
twice with list-filesystems, inspect-os, inspect-get-roots, etc... I'm seeing
this in version 1.26, but haven't found anything directly resolving this in
newer versions.
These commands all show the partition listed twice as in the following output:
><fs> inspect-get-roots
/dev/sda2
btrfsvol:/dev/sda2/@
The output above complicates the existing virt-v2v process, as it prompts
users to select the appropriate root filesystem. (Either one works for the
conversion.) I've patched v2v to strip out the duplicate 'btrfsvol' entry if
the partition itself is in both strings, but wanted to run the problem past
the list before working around it at that level.
Has this issue been seen before?
For the record, here's the full filesystem list:
><fs> list-filesystems
/dev/sda1: swap
btrfsvol:/dev/sda2/@: btrfs
btrfsvol:/dev/sda2/boot/grub2/i386-pc: btrfs
btrfsvol:/dev/sda2/boot/grub2/x86_64-efi: btrfs
btrfsvol:/dev/sda2/home: btrfs
btrfsvol:/dev/sda2/opt: btrfs
btrfsvol:/dev/sda2/srv: btrfs
btrfsvol:/dev/sda2/tmp: btrfs
btrfsvol:/dev/sda2/usr/local: btrfs
btrfsvol:/dev/sda2/var/crash: btrfs
btrfsvol:/dev/sda2/var/lib/mailman: btrfs
btrfsvol:/dev/sda2/var/lib/named: btrfs
btrfsvol:/dev/sda2/var/lib/pgqsl: btrfs
btrfsvol:/dev/sda2/var/log: btrfs
btrfsvol:/dev/sda2/var/opt: btrfs
btrfsvol:/dev/sda2/var/spool: btrfs
btrfsvol:/dev/sda2/var/tmp: btrfs
btrfsvol:/dev/sda2/.snapshots: btrfs
/dev/sda2: btrfs
Thanks!
Mike
10 years, 7 months
[PATCH 1/2] tar-in: Fix places where we didn't cancel the receive (FileIn) correctly along error paths (RHBZ#1091803).
by Richard W.M. Jones
Thanks: Bo Fan.
---
daemon/tar.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/daemon/tar.c b/daemon/tar.c
index 548eb89..6723f3a 100644
--- a/daemon/tar.c
+++ b/daemon/tar.c
@@ -47,11 +47,14 @@ is_chown_supported (const char *dir)
{
size_t len = sysroot_len + strlen (dir) + 64;
char buf[len];
- int fd, r, saved_errno;
+ int fd, r, err, saved_errno;
/* Create a randomly named file. */
snprintf (buf, len, "%s%s/XXXXXXXX.XXX", sysroot, dir);
if (random_name (buf) == -1) {
+ err = errno;
+ r = cancel_receive ();
+ errno = err;
reply_with_perror ("random_name");
return -1;
}
@@ -59,6 +62,9 @@ is_chown_supported (const char *dir)
/* Maybe 'dir' is not a directory or filesystem not writable? */
fd = open (buf, O_WRONLY|O_CREAT|O_NOCTTY|O_CLOEXEC, 0666);
if (fd == -1) {
+ err = errno;
+ r = cancel_receive ();
+ errno = err;
reply_with_perror ("%s", dir);
return -1;
}
@@ -78,6 +84,9 @@ is_chown_supported (const char *dir)
if (r == -1) {
/* Some other error? */
+ err = errno;
+ r = cancel_receive ();
+ errno = err;
reply_with_perror_errno (saved_errno, "unexpected error in fchown");
return -1;
}
@@ -153,6 +162,9 @@ do_tar_in (const char *dir, const char *compress)
fd = mkstemp (error_file);
if (fd == -1) {
+ err = errno;
+ r = cancel_receive ();
+ errno = err;
reply_with_perror ("mkstemp");
return -1;
}
--
1.8.5.3
10 years, 7 months
[HIVEX] port ruby tests to MiniTest (#1090407)
by Pino Toscano
Just like it has been done in libguestfs, port the ruby tests in hivex
from Test::Unit to MiniTest, keeping backward compatibility with the old
test framework.
Pino Toscano (2):
ruby: tests: isolate boilerplate in common file
ruby: tests: convert from Test::Unit to MiniTest (RHBZ#1090407)
ruby/Makefile.am | 3 ++-
ruby/tests/tc_010_load.rb | 9 ++++-----
ruby/tests/tc_021_close.rb | 9 ++++-----
ruby/tests/tc_120_rlenvalue.rb | 13 ++++++-------
ruby/tests/tc_130_special.rb | 9 ++++-----
ruby/tests/tc_200_write.rb | 9 ++++-----
ruby/tests/tc_210_setvalue.rb | 9 ++++-----
ruby/tests/test_helper.rb | 31 +++++++++++++++++++++++++++++++
8 files changed, 59 insertions(+), 33 deletions(-)
create mode 100644 ruby/tests/test_helper.rb
--
1.9.0
10 years, 7 months