Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
libvirt
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Libvirt Packaging Team
libvirt
Commits
7546785e
Commit
7546785e
authored
13 years ago
by
Guido Günther
Browse files
Options
Downloads
Patches
Plain Diff
Drop patch storage-forbid-rebuilding-existing-disk-storage-pool
applied upstream.
parent
f30713c0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
debian/patches/series
+0
-1
0 additions, 1 deletion
debian/patches/series
debian/patches/storage-forbid-rebuilding-existing-disk-storage-pool.patch
+0
-112
0 additions, 112 deletions
...torage-forbid-rebuilding-existing-disk-storage-pool.patch
with
0 additions
and
113 deletions
debian/patches/series
+
0
−
1
View file @
7546785e
...
...
@@ -9,4 +9,3 @@ virsh-Initialize-library-before-calling-virResetLast.patch
Disable-daemon-start-test.patch
Disable-gnulib-s-test-nonplocking-pipe.sh.patch
Disable-failing-virnetsockettest.patch
storage-forbid-rebuilding-existing-disk-storage-pool.patch
This diff is collapsed.
Click to expand it.
debian/patches/storage-forbid-rebuilding-existing-disk-storage-pool.patch
deleted
100644 → 0
+
0
−
112
View file @
f30713c0
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Sat, 12 Nov 2011 13:31:52 +0100
Subject: storage: forbid rebuilding existing disk storage pools
which would blow away all volumes. Honor VIR_STORAGE_POOL_BUILD_OVERWRITE
to force a rebuild.
This was caught by libvirt-tck's storage/110-disk-pool.t.
---
src/storage/storage_backend_disk.c | 72 ++++++++++++++++++++++++++++++++++--
1 files changed, 68 insertions(+), 4 deletions(-)
diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index 82d6e8a..995ad2f 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -335,6 +335,40 @@
virStorageBackendDiskRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
/**
+ * Check for a valid disk label (partition table) on device
+ *
+ * return: 0 - valid disk label found
+ * >0 - no or unrecognized disk label
+ * <0 - error finding the disk label
+ */
+static int
+virStorageBackendDiskFindLabel(const char* device)
+{
+ const char *const args[] = {
+ device, "print", "--script", NULL,
+ };
+ virCommandPtr cmd = virCommandNew(PARTED);
+ char *output = NULL;
+ int ret = -1;
+
+ virCommandAddArgSet(cmd, args);
+ virCommandAddEnvString(cmd, "LC_ALL=C");
+ virCommandSetOutputBuffer(cmd, &output);
+
+ /* if parted succeeds we have a valid partition table */
+ ret = virCommandRun(cmd, NULL);
+ if (ret < 0) {
+ if (strstr (output, "unrecognised disk label"))
+ ret = 1;
+ }
+
+ virCommandFree(cmd);
+ VIR_FREE(output);
+ return ret;
+}
+
+
+/**
* Write a new partition table header
*/
static int
@@ -342,6 +376,8 @@
virStorageBackendDiskBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED,
virStoragePoolObjPtr pool,
unsigned int flags)
{
+ bool ok_to_mklabel = false;
+ int ret = -1;
/* eg parted /dev/sda mklabel msdos */
const char *prog[] = {
PARTED,
@@ -353,12 +389,40 @@
virStorageBackendDiskBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED,
NULL,
};
- virCheckFlags(0, -1);
+ virCheckFlags(VIR_STORAGE_POOL_BUILD_OVERWRITE |
+ VIR_STORAGE_POOL_BUILD_NO_OVERWRITE, ret);
- if (virRun(prog, NULL) < 0)
- return -1;
+ if (flags == (VIR_STORAGE_POOL_BUILD_OVERWRITE |
+ VIR_STORAGE_POOL_BUILD_NO_OVERWRITE)) {
+ virStorageReportError(VIR_ERR_OPERATION_INVALID,
+ _("Overwrite and no overwrite flags"
+ " are mutually exclusive"));
+ goto error;
+ }
- return 0;
+ if (flags & VIR_STORAGE_POOL_BUILD_OVERWRITE)
+ ok_to_mklabel = true;
+ else {
+ int check;
+
+ check = virStorageBackendDiskFindLabel (
+ pool->def->source.devices[0].path);
+ if (check > 0) {
+ ok_to_mklabel = true;
+ } else if (check < 0) {
+ virStorageReportError(VIR_ERR_OPERATION_FAILED,
+ _("Error checking for disk label"));
+ } else {
+ virStorageReportError(VIR_ERR_OPERATION_INVALID,
+ _("Disk label already present"));
+ }
+ }
+
+ if (ok_to_mklabel)
+ ret = virRun(prog, NULL);
+
+error:
+ return ret;
}
/**
--
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment