diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-06-25 09:03:39 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-06-25 11:20:35 +0100 |
commit | 729bb9c6b5ae0c0e7c68dc802b1617936062f966 (patch) | |
tree | 29d163c888a727dec893bde7277a8f452f235420 /src/launch.c | |
parent | 78a515ec4a4e8650bd2e1ffc0bfbb97b9568306d (diff) | |
download | libguestfs-729bb9c6b5ae0c0e7c68dc802b1617936062f966.tar.gz libguestfs-729bb9c6b5ae0c0e7c68dc802b1617936062f966.tar.xz libguestfs-729bb9c6b5ae0c0e7c68dc802b1617936062f966.zip |
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.
Diffstat (limited to 'src/launch.c')
-rw-r--r-- | src/launch.c | 19 |
1 files changed, 19 insertions, 0 deletions
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. |