From 729bb9c6b5ae0c0e7c68dc802b1617936062f966 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 25 Jun 2012 09:03:39 +0100 Subject: launch: Treat /dev/null specially, for old KVM. Old KVM can't add /dev/null readonly. Treat /dev/null as a special case. We also fix a few tests where /dev/null was being used with format=qcow2. This was always incorrect behaviour, but qemu appears to tolerate it. --- src/launch.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/launch.c') diff --git a/src/launch.c b/src/launch.c index 72eca511..cd785014 100644 --- a/src/launch.c +++ b/src/launch.c @@ -347,6 +347,7 @@ guestfs__add_drive_opts (guestfs_h *g, const char *filename, char *iface; char *name; int use_cache_off; + int is_null; if (strchr (filename, ':') != NULL) { error (g, _("filename cannot contain ':' (colon) character. " @@ -374,6 +375,24 @@ guestfs__add_drive_opts (guestfs_h *g, const char *filename, goto err_out; } + /* Traditionally you have been able to use /dev/null as a filename, + * as many times as you like. Treat this as a special case, because + * old versions of qemu have some problems. + */ + is_null = STREQ (filename, "/dev/null"); + if (is_null) { + if (format && STRNEQ (format, "raw")) { + error (g, _("for device '/dev/null', format must be 'raw'")); + goto err_out; + } + /* Ancient KVM (RHEL 5) cannot handle the case where we try to add + * a snapshot on top of /dev/null. Modern qemu can handle it OK, + * but the device size is still 0, so it shouldn't matter whether + * or not this is readonly. + */ + readonly = 0; + } + /* For writable files, see if we can use cache=off. This also * checks for the existence of the file. For readonly we have * to do the check explicitly. -- cgit