virtio_blk is the fast, virt-native block device driver
supported by qemu and KVM. Note that virtio_blk device
names are called /dev/vd*.
Existing scripts should continue working because device name
translation will silently change device names of the form
/dev/sd* to /dev/vd* as required.
See also:
http://libguestfs.org/guestfs.3.html#block_device_naming
while ((d = readdir (dir)) != NULL) {
if (strncmp (d->d_name, "sd", 2) == 0 ||
while ((d = readdir (dir)) != NULL) {
if (strncmp (d->d_name, "sd", 2) == 0 ||
- strncmp (d->d_name, "hd", 2) == 0) {
+ strncmp (d->d_name, "hd", 2) == 0 ||
+ strncmp (d->d_name, "vd", 2) == 0) {
snprintf (buf, sizeof buf, "/dev/%s", d->d_name);
if (add_string (&r, &size, &alloc, buf) == -1) {
closedir (dir);
snprintf (buf, sizeof buf, "/dev/%s", d->d_name);
if (add_string (&r, &size, &alloc, buf) == -1) {
closedir (dir);
while ((d = readdir (dir)) != NULL) {
if (strncmp (d->d_name, "sd", 2) == 0 ||
while ((d = readdir (dir)) != NULL) {
if (strncmp (d->d_name, "sd", 2) == 0 ||
- strncmp (d->d_name, "hd", 2) == 0) {
+ strncmp (d->d_name, "hd", 2) == 0 ||
+ strncmp (d->d_name, "vd", 2) == 0) {
strncpy (devname, d->d_name, sizeof devname);
devname[sizeof devname - 1] = '\0';
strncpy (devname, d->d_name, sizeof devname);
devname[sizeof devname - 1] = '\0';
+ if (errno != ENXIO && errno != ENOENT) {
error:
reply_with_perror ("%s: %s", func, device);
return -1;
error:
reply_with_perror ("%s: %s", func, device);
return -1;
* 50MB and 10MB (respectively /dev/sda, /dev/sdb, /dev/sdc), and
* a fourth squashfs block device with some known files on it (/dev/sdd).
*
* 50MB and 10MB (respectively /dev/sda, /dev/sdb, /dev/sdc), and
* a fourth squashfs block device with some known files on it (/dev/sdd).
*
- * Note for partitioning purposes, the 500MB device has 63 cylinders.
+ * Note for partitioning purposes, the 500MB device has 1015 cylinders.
+ * Number of cylinders was 63 for IDE emulated disks with precisely
+ * the same size. How exactly this is calculated is a mystery.
*
* The squashfs block device (/dev/sdd) comes from images/test.sqsh.
*
*
* The squashfs block device (/dev/sdd) comes from images/test.sqsh.
*
just want to read the image or write access if you want to modify the
image).
just want to read the image or write access if you want to modify the
image).
-This is equivalent to the qemu parameter C<-drive file=filename,cache=off>.
+This is equivalent to the qemu parameter
+C<-drive file=filename,cache=off,if=virtio>.
Note that this call checks for the existence of C<filename>. This
stops you from specifying other types of drive which are supported
Note that this call checks for the existence of C<filename>. This
stops you from specifying other types of drive which are supported
changes to be committed, although qemu can support this.
This is equivalent to the qemu parameter
changes to be committed, although qemu can support this.
This is equivalent to the qemu parameter
-C<-drive file=filename,snapshot=on>.
+C<-drive file=filename,snapshot=on,if=virtio>.
Note that this call checks for the existence of C<filename>. This
stops you from specifying other types of drive which are supported
Note that this call checks for the existence of C<filename>. This
stops you from specifying other types of drive which are supported
[InitBasicFS, Always, TestOutputListOfDevices (
[["list_partitions"]], ["/dev/sda1"]);
InitEmpty, Always, TestOutputListOfDevices (
[InitBasicFS, Always, TestOutputListOfDevices (
[["list_partitions"]], ["/dev/sda1"]);
InitEmpty, Always, TestOutputListOfDevices (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ",10 ,20 ,"];
+ [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ",200 ,400 ,"];
["list_partitions"]], ["/dev/sda1"; "/dev/sda2"; "/dev/sda3"])],
"list the partitions",
"\
["list_partitions"]], ["/dev/sda1"; "/dev/sda2"; "/dev/sda3"])],
"list the partitions",
"\
[InitBasicFSonLVM, Always, TestOutputListOfDevices (
[["pvs"]], ["/dev/sda1"]);
InitEmpty, Always, TestOutputListOfDevices (
[InitBasicFSonLVM, Always, TestOutputListOfDevices (
[["pvs"]], ["/dev/sda1"]);
InitEmpty, Always, TestOutputListOfDevices (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ",10 ,20 ,"];
+ [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ",200 ,400 ,"];
["pvcreate"; "/dev/sda1"];
["pvcreate"; "/dev/sda2"];
["pvcreate"; "/dev/sda3"];
["pvcreate"; "/dev/sda1"];
["pvcreate"; "/dev/sda2"];
["pvcreate"; "/dev/sda3"];
[InitBasicFSonLVM, Always, TestOutputList (
[["vgs"]], ["VG"]);
InitEmpty, Always, TestOutputList (
[InitBasicFSonLVM, Always, TestOutputList (
[["vgs"]], ["VG"]);
InitEmpty, Always, TestOutputList (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ",10 ,20 ,"];
+ [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ",200 ,400 ,"];
["pvcreate"; "/dev/sda1"];
["pvcreate"; "/dev/sda2"];
["pvcreate"; "/dev/sda3"];
["pvcreate"; "/dev/sda1"];
["pvcreate"; "/dev/sda2"];
["pvcreate"; "/dev/sda3"];
[InitBasicFSonLVM, Always, TestOutputList (
[["lvs"]], ["/dev/VG/LV"]);
InitEmpty, Always, TestOutputList (
[InitBasicFSonLVM, Always, TestOutputList (
[["lvs"]], ["/dev/VG/LV"]);
InitEmpty, Always, TestOutputList (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ",10 ,20 ,"];
+ [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ",200 ,400 ,"];
["pvcreate"; "/dev/sda1"];
["pvcreate"; "/dev/sda2"];
["pvcreate"; "/dev/sda3"];
["pvcreate"; "/dev/sda1"];
["pvcreate"; "/dev/sda2"];
["pvcreate"; "/dev/sda3"];
("pvcreate", (RErr, [String "device"]), 39, [],
[InitEmpty, Always, TestOutputListOfDevices (
("pvcreate", (RErr, [String "device"]), 39, [],
[InitEmpty, Always, TestOutputListOfDevices (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ",10 ,20 ,"];
+ [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ",200 ,400 ,"];
["pvcreate"; "/dev/sda1"];
["pvcreate"; "/dev/sda2"];
["pvcreate"; "/dev/sda3"];
["pvcreate"; "/dev/sda1"];
["pvcreate"; "/dev/sda2"];
["pvcreate"; "/dev/sda3"];
("vgcreate", (RErr, [String "volgroup"; StringList "physvols"]), 40, [],
[InitEmpty, Always, TestOutputList (
("vgcreate", (RErr, [String "volgroup"; StringList "physvols"]), 40, [],
[InitEmpty, Always, TestOutputList (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ",10 ,20 ,"];
+ [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ",200 ,400 ,"];
["pvcreate"; "/dev/sda1"];
["pvcreate"; "/dev/sda2"];
["pvcreate"; "/dev/sda3"];
["pvcreate"; "/dev/sda1"];
["pvcreate"; "/dev/sda2"];
["pvcreate"; "/dev/sda3"];
("lvcreate", (RErr, [String "logvol"; String "volgroup"; Int "mbytes"]), 41, [],
[InitEmpty, Always, TestOutputList (
("lvcreate", (RErr, [String "logvol"; String "volgroup"; Int "mbytes"]), 41, [],
[InitEmpty, Always, TestOutputList (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ",10 ,20 ,"];
+ [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ",200 ,400 ,"];
["pvcreate"; "/dev/sda1"];
["pvcreate"; "/dev/sda2"];
["pvcreate"; "/dev/sda3"];
["pvcreate"; "/dev/sda1"];
["pvcreate"; "/dev/sda2"];
["pvcreate"; "/dev/sda3"];
["mounts"]], []);
(* check that umount_all can unmount nested mounts correctly: *)
InitEmpty, Always, TestOutputList (
["mounts"]], []);
(* check that umount_all can unmount nested mounts correctly: *)
InitEmpty, Always, TestOutputList (
- [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ",10 ,20 ,"];
+ [["sfdisk"; "/dev/sda"; "0"; "0"; "0"; ",200 ,400 ,"];
["mkfs"; "ext2"; "/dev/sda1"];
["mkfs"; "ext2"; "/dev/sda2"];
["mkfs"; "ext2"; "/dev/sda3"];
["mkfs"; "ext2"; "/dev/sda1"];
["mkfs"; "ext2"; "/dev/sda2"];
["mkfs"; "ext2"; "/dev/sda3"];
See also: C<guestfs_scrub_device>.");
("grub_install", (RErr, [String "root"; String "device"]), 86, [],
See also: C<guestfs_scrub_device>.");
("grub_install", (RErr, [String "root"; String "device"]), 86, [],
- [InitBasicFS, Always, TestOutputTrue (
+ (* Test disabled because grub-install incompatible with virtio-blk driver.
+ * See also: https://bugzilla.redhat.com/show_bug.cgi?id=479760
+ *)
+ [InitBasicFS, Disabled, TestOutputTrue (
[["grub_install"; "/"; "/dev/sda1"];
["is_dir"; "/boot"]])],
"install GRUB",
[["grub_install"; "/"; "/dev/sda1"];
["is_dir"; "/boot"]])],
"install GRUB",
}
/* cache=off improves reliability in the event of a host crash. */
}
/* cache=off improves reliability in the event of a host crash. */
- snprintf (buf, len, "file=%s,cache=off", filename);
+ snprintf (buf, len, "file=%s,cache=off,if=virtio", filename);
return guestfs_config (g, "-drive", buf);
}
return guestfs_config (g, "-drive", buf);
}
- snprintf (buf, len, "file=%s,snapshot=on", filename);
+ snprintf (buf, len, "file=%s,snapshot=on,if=virtio", filename);
return guestfs_config (g, "-drive", buf);
}
return guestfs_config (g, "-drive", buf);
}