]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Fix Xen Virtual Block Device detection
authorRichard Yao <ryao@gentoo.org>
Mon, 6 Jul 2015 15:20:11 +0000 (11:20 -0400)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 10 Jul 2015 19:21:14 +0000 (12:21 -0700)
We fail to make partitions on xvd (Xen Virtual Block) devices. This also
causes debug builds of zpool create to return an error when given xen
virtual block devices. These devices should be given the same treatment
as vd (KVM Virtual Block) devices, so we adjust the relevant code paths.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3576

lib/libefi/rdwr_efi.c
lib/libzfs/libzfs_pool.c

index 24ec365b5a9fd1c71331345252d4b5a24b14874e..b3905d7f3bfd14b3db7a5734c07114dd59a10ab0 100644 (file)
@@ -204,6 +204,12 @@ efi_get_info(int fd, struct dk_cinfo *dki_info)
                rval = sscanf(dev_path, "/dev/%[a-zA-Z]%hu",
                    dki_info->dki_dname,
                    &dki_info->dki_partition);
+       } else if ((strncmp(dev_path, "/dev/xvd", 8) == 0)) {
+               strcpy(dki_info->dki_cname, "xvd");
+               dki_info->dki_ctype = DKC_MD;
+               rval = sscanf(dev_path, "/dev/%[a-zA-Z]%hu",
+                   dki_info->dki_dname,
+                   &dki_info->dki_partition);
        } else if ((strncmp(dev_path, "/dev/dm-", 8) == 0)) {
                strcpy(dki_info->dki_cname, "pseudo");
                dki_info->dki_ctype = DKC_VBD;
index fe26abeb72357edfd8392300fc0897a75c5eb626..a730a94e081a262143aabb67fb4918889e0972db 100644 (file)
@@ -3378,7 +3378,7 @@ set_path(zpool_handle_t *zhp, nvlist_t *nv, const char *path)
  * forms: "-partX", "pX", or "X", where X is a string of digits.  The second
  * case only occurs when the suffix is preceded by a digit, i.e. "md0p0" The
  * third case only occurs when preceded by a string matching the regular
- * expression "^[hs]d[a-z]+", i.e. a scsi or ide disk.
+ * expression "^([hsv]|xv)d[a-z]+", i.e. a scsi, ide, virtio or xen disk.
  */
 static char *
 strip_partition(libzfs_handle_t *hdl, char *path)
@@ -3391,8 +3391,11 @@ strip_partition(libzfs_handle_t *hdl, char *path)
        } else if ((part = strrchr(tmp, 'p')) &&
            part > tmp + 1 && isdigit(*(part-1))) {
                d = part + 1;
-       } else if ((tmp[0] == 'h' || tmp[0] == 's') && tmp[1] == 'd') {
+       } else if ((tmp[0] == 'h' || tmp[0] == 's' || tmp[0] == 'v') &&
+           tmp[1] == 'd') {
                for (d = &tmp[2]; isalpha(*d); part = ++d);
+       } else if (strncmp("xvd", tmp, 3) == 0) {
+               for (d = &tmp[3]; isalpha(*d); part = ++d);
        }
        if (part && d && *d != '\0') {
                for (; isdigit(*d); d++);