From: Daniel P. Berrange Date: Wed, 5 Feb 2014 11:01:09 +0000 (+0000) Subject: Disks are always block devices, never character devices X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43d0716d83835a23a9749f978a437189a2a11306;p=thirdparty%2Flibvirt.git Disks are always block devices, never character devices The LXC disk hotplug code was allowing block or character devices to be given as disk. A disk is always a block device. Signed-off-by: Daniel P. Berrange (cherry picked from commit d24e6b8b1eb87daa6ee467b76cf343725468949c) --- diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index f2aa52e85d..562577c3cf 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -3161,9 +3161,9 @@ lxcDomainAttachDeviceDiskLive(virLXCDriverPtr driver, goto cleanup; } - if (!S_ISCHR(sb.st_mode) && !S_ISBLK(sb.st_mode)) { + if (!S_ISBLK(sb.st_mode)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Disk source %s must be a character/block device"), + _("Disk source %s must be a block device"), def->src); goto cleanup; } @@ -3179,11 +3179,7 @@ lxcDomainAttachDeviceDiskLive(virLXCDriverPtr driver, goto cleanup; } - mode = 0700; - if (S_ISCHR(sb.st_mode)) - mode |= S_IFCHR; - else - mode |= S_IFBLK; + mode = 0700 | S_IFBLK; /* Yes, the device name we're creating may not * actually correspond to the major:minor number