diff --git a/src/storage/parthelper.c b/src/storage/parthelper.c index 8de32fd5c7b2cc975923674fe5f90b4dc4add230..d1df068f233f3e2f84a8c69a436558bf01c0ec3a 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 a83e34080e1fb17d38a3fc2539f51eae6a502de8..3e0395dec9790f1575311d750eba26ba8f55814f 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. */