Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 852715 Details for
Bug 1055479
Libvirt lose sheepdogs volumes on pool refresh or restart
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Possible patch
storage_backend_sheepdog.c.diff (text/plain), 4.08 KB, created by
joel.simoes
on 2014-01-20 11:18:03 UTC
(
hide
)
Description:
Possible patch
Filename:
MIME Type:
Creator:
joel.simoes
Created:
2014-01-20 11:18:03 UTC
Size:
4.08 KB
patch
obsolete
>diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_backend_sheepdog.c >index a6981ce..5bcad03 100644 >--- a/src/storage/storage_backend_sheepdog.c >+++ b/src/storage/storage_backend_sheepdog.c >@@ -34,6 +34,7 @@ > #include "viralloc.h" > #include "virlog.h" > #include "virstring.h" >+#include <assert.h> > > #define VIR_FROM_THIS VIR_FROM_STORAGE > >@@ -44,6 +45,56 @@ static int virStorageBackendSheepdogRefreshVol(virConnectPtr conn, > void virStorageBackendSheepdogAddHostArg(virCommandPtr cmd, > virStoragePoolObjPtr pool); > >+char** str_split(char* a_str, const char a_delim); >+ >+char** str_split(char* a_str, const char a_delim) { >+ char** result = 0; >+ size_t count = 0; >+ >+ >+ char* tmp = a_str; >+ >+ >+ char* last_comma = 0; >+ char delim[2]; >+ delim[0] = a_delim; >+ delim[1] = 0; >+ >+ /* Count how many elements will be extracted. */ >+ while (*tmp) { >+ if (a_delim == *tmp) { >+ count++; >+ last_comma = tmp; >+ } >+ tmp++; >+ } >+ >+ /* Add space for trailing token. */ >+ count += last_comma < (a_str + strlen(a_str) - 1); >+ >+ /* Add space for terminating null string so caller >+ knows where the list of returned strings ends. */ >+ count++; >+ >+ result = malloc(sizeof (char*) * count); >+ >+ >+ if (result) { >+ size_t idx = 0; >+ char* token = strtok(a_str, delim); >+ >+ while (token) { >+ assert(idx < count); >+ *(result + idx++) = strdup(token); >+ token = strtok(0, delim); >+ } >+ assert(idx == count - 1); >+ *(result + idx) = 0; >+ } >+ >+ return result; >+} >+ > int > virStorageBackendSheepdogParseNodeInfo(virStoragePoolDefPtr pool, > char *output) >@@ -111,6 +162,69 @@ virStorageBackendSheepdogAddHostArg(virCommandPtr cmd, > > > static int >+virStorageBackendSheepdogRefreshAllVol(virConnectPtr conn ATTRIBUTE_UNUSED, >+ virStoragePoolObjPtr pool) { >+ int ret; >+ char *output = NULL; >+ >+ virCommandPtr cmd = virCommandNewArgList(COLLIE, "vdi", "list", "-r", NULL); >+ virStorageBackendSheepdogAddHostArg(cmd, pool); >+ virCommandSetOutputBuffer(cmd, &output); >+ ret = virCommandRun(cmd, NULL); >+ char** lines; >+ lines = (char**) str_split(output, '\n'); >+ int i; >+ for (i = 0; *(lines + i); i++) { >+ char *line = *(lines + i); >+ char** cells; >+ cells = (char**) str_split(line, ' '); >+ int j; >+ for (j = 0; *(cells + j); j++) { >+ >+ char *cell = *(cells + j); >+ if (j == 1) { >+ virStorageVolDefPtr vol = NULL; >+ if (VIR_ALLOC(vol) < 0) >+ goto cleanup; >+ >+ if (VIR_STRDUP(vol->name, cell) < 0) >+ goto cleanup; >+ >+ vol->type = VIR_STORAGE_VOL_BLOCK; >+ >+ >+ if (VIR_REALLOC_N(pool->volumes.objs, >+ pool->volumes.count + 1) < 0) >+ goto cleanup; >+ pool->volumes.objs[pool->volumes.count++] = vol; >+ >+ if (virStorageBackendSheepdogRefreshVol(conn, pool, vol) < 0) >+ goto cleanup; >+ >+ vol = NULL; >+ } >+ >+ free(*(cells + j)); >+ } >+ >+ free(cells); >+ free(*(lines + i)); >+ } >+ >+ >+ free(lines); >+ >+ if (ret < 0) >+ goto cleanup; >+ >+ >+cleanup: >+ virCommandFree(cmd); >+ return ret; >+} >+ >+ >+static int > virStorageBackendSheepdogRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, > virStoragePoolObjPtr pool) > { >@@ -122,9 +236,10 @@ virStorageBackendSheepdogRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, > virStorageBackendSheepdogAddHostArg(cmd, pool); > virCommandSetOutputBuffer(cmd, &output); > ret = virCommandRun(cmd, NULL); >- if (ret == 0) >+ if (ret == 0){ > ret = virStorageBackendSheepdogParseNodeInfo(pool->def, output); >- >+ virStorageBackendSheepdogRefreshAllVol(conn, pool); >+ } > virCommandFree(cmd); > VIR_FREE(output); > return ret;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1055479
: 852715