https://bugzilla.redhat.com/show_bug.cgi?id=1265694
In order to be able to process disk storage pool's using a multipath
device to handle the partitions, libvirt_parthelper will need a way to
not automatically add a partition separator "p" to the generated device
name for each partition found. This is designed to mimic the multipath
features known as 'user_friendly_names' and custom 'alias' name.
If the part_separator attribute is set to "no", then generation of the
multipath partition name will not include the "p" partition separator
unless the source device path name ends with a number. The generated
partition names that get passed back to libvirt are processed in order
to find the device mapper multipath (dm-#) path device.
For example, device path "/dev/mapper/mpatha" would create partitions
"/dev/mapper/mpatha1", "/dev/mapper/mpatha2", etc. instead of
"/dev/mapper/mpathap1", "/dev/mapper/mpathap2", etc. If the device
path ends with a number "/dev/mapper/mpatha1", then the algorithm
to generate names "/dev/mapper/mpatha1p1", "/dev/mapper/mpatha1p2",
etc.
would be utilized.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/storage/parthelper.c | 15 ++++++++++++---
src/storage/storage_backend_disk.c | 11 ++++++++++-
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/src/storage/parthelper.c b/src/storage/parthelper.c
index 8de32fd..d1df068 100644
--- a/src/storage/parthelper.c
+++ b/src/storage/parthelper.c
@@ -10,7 +10,7 @@
* in a reliable fashion if merely after a list of partitions & sizes,
* though it is fine for creating partitions.
*
- * Copyright (C) 2007-2008, 2010, 2013 Red Hat, Inc.
+ * Copyright (C) 2007-2008, 2010, 2013, 2016 Red Hat, Inc.
* Copyright (C) 2007-2008 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -70,6 +70,7 @@ int main(int argc, char **argv)
const char *path;
char *canonical_path;
const char *partsep;
+ bool devmap_nopartsep = false;
if (setlocale(LC_ALL, "") == NULL ||
bindtextdomain(PACKAGE, LOCALEDIR) == NULL ||
@@ -80,14 +81,22 @@ int main(int argc, char **argv)
if (argc == 3 && STREQ(argv[2], "-g")) {
cmd = DISK_GEOMETRY;
+ } else if (argc == 3 && STREQ(argv[2], "-p")) {
+ devmap_nopartsep = true;
} else if (argc != 2) {
- fprintf(stderr, _("syntax: %s DEVICE [-g]\n"), argv[0]);
+ fprintf(stderr, _("syntax: %s DEVICE [-g]|[-p]\n"), argv[0]);
return 1;
}
path = argv[1];
if (virIsDevMapperDevice(path)) {
- partsep = "p";
+ /* The 'devmap_nopartsep' option will not append the partsep of
"p"
+ * onto the name unless the 'path' ends in a number
+ */
+ if (c_isdigit(path[strlen(path)-1]) || !devmap_nopartsep)
+ partsep = "p";
+ else
+ partsep = "";
if (VIR_STRDUP_QUIET(canonical_path, path) < 0)
return 2;
} else {
diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index a83e340..3e0395d 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -1,7 +1,7 @@
/*
* storage_backend_disk.c: storage backend for disk handling
*
- * Copyright (C) 2007-2014 Red Hat, Inc.
+ * Copyright (C) 2007-2016 Red Hat, Inc.
* Copyright (C) 2007-2008 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -325,6 +325,15 @@ virStorageBackendDiskReadPartitions(virStoragePoolObjPtr pool,
pool->def->source.devices[0].path,
NULL);
+ /* Check for the presence of the part_separator='no'. Pass this
+ * along to the libvirt_parthelper as option '-p'. This will cause
+ * libvirt_parthelper to not append the "p" partition separator to
+ * the generated device name, unless the name ends with a number.
+ */
+ if (pool->def->source.devices[0].part_separator ==
+ VIR_TRISTATE_BOOL_NO)
+ virCommandAddArg(cmd, "-p");
+
/* If a volume is passed, virStorageBackendDiskMakeVol only updates the
* pool allocation for that single volume.
*/
--
2.5.0