summaryrefslogtreecommitdiffstats
path: root/src/guestfs.c
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2010-02-12 11:47:18 +0000
committerRichard Jones <rjones@redhat.com>2010-02-12 11:47:18 +0000
commit946dc06bb861a38cae959416362e4561c9e4829a (patch)
treef2b53c33ed7b9b32b676713100c9b9d8b18404b7 /src/guestfs.c
parent48a9ff73319d0d065bff2b9374c84bcf6438cb20 (diff)
downloadlibguestfs-946dc06bb861a38cae959416362e4561c9e4829a.tar.gz
libguestfs-946dc06bb861a38cae959416362e4561c9e4829a.tar.xz
libguestfs-946dc06bb861a38cae959416362e4561c9e4829a.zip
New APIs: add-drive{,-ro}-with-if allows you to set QEMU block emulation.
The default if=... comes from configure time (currently it defaults to if=virtio). This change allows you to set the QEMU block emulation. We don't think this will be used very often, but virt-v2v requires it in order to work around a subtle problem with running 'mkinitrd' in an appliance attached to a guest.
Diffstat (limited to 'src/guestfs.c')
-rw-r--r--src/guestfs.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/guestfs.c b/src/guestfs.c
index 9908e7f8..3c00114f 100644
--- a/src/guestfs.c
+++ b/src/guestfs.c
@@ -748,7 +748,8 @@ guestfs__config (guestfs_h *g,
}
int
-guestfs__add_drive (guestfs_h *g, const char *filename)
+guestfs__add_drive_with_if (guestfs_h *g, const char *filename,
+ const char *drive_if)
{
size_t len = strlen (filename) + 64;
char buf[len];
@@ -771,12 +772,12 @@ guestfs__add_drive (guestfs_h *g, const char *filename)
int fd = open (filename, O_RDONLY|O_DIRECT);
if (fd >= 0) {
close (fd);
- snprintf (buf, len, "file=%s,cache=off,if=" DRIVE_IF, filename);
+ snprintf (buf, len, "file=%s,cache=off,if=%s", filename, drive_if);
} else {
fd = open (filename, O_RDONLY);
if (fd >= 0) {
close (fd);
- snprintf (buf, len, "file=%s,if=" DRIVE_IF, filename);
+ snprintf (buf, len, "file=%s,if=%s", filename, drive_if);
} else {
perrorf (g, "%s", filename);
return -1;
@@ -787,7 +788,8 @@ guestfs__add_drive (guestfs_h *g, const char *filename)
}
int
-guestfs__add_drive_ro (guestfs_h *g, const char *filename)
+guestfs__add_drive_ro_with_if (guestfs_h *g, const char *filename,
+ const char *drive_if)
{
size_t len = strlen (filename) + 64;
char buf[len];
@@ -802,12 +804,24 @@ guestfs__add_drive_ro (guestfs_h *g, const char *filename)
return -1;
}
- snprintf (buf, len, "file=%s,snapshot=on,if=%s", filename, DRIVE_IF);
+ snprintf (buf, len, "file=%s,snapshot=on,if=%s", filename, drive_if);
return guestfs__config (g, "-drive", buf);
}
int
+guestfs__add_drive (guestfs_h *g, const char *filename)
+{
+ return guestfs__add_drive_with_if (g, filename, DRIVE_IF);
+}
+
+int
+guestfs__add_drive_ro (guestfs_h *g, const char *filename)
+{
+ return guestfs__add_drive_ro_with_if (g, filename, DRIVE_IF);
+}
+
+int
guestfs__add_cdrom (guestfs_h *g, const char *filename)
{
if (strchr (filename, ',') != NULL) {