* src/storage/storage_backend.c (createRawFileOpHook): Change
signature.
(struct createRawFileOpHookData): Delete unused struct.
(virStorageBackendCreateRaw): Adjust caller.
* src/qemu/qemu_driver.c (struct fileOpHookData): Delete unused
struct.
(qemudDomainSaveFileOpHook): Rename...
(qemuDomainSaveFileOpHook): ...and change signature.
(qemudDomainSaveFlag): Adjust caller.
---
v3: new patch
src/qemu/qemu_driver.c | 29 +++++++++--------------------
src/storage/storage_backend.c | 32 ++++++++++++--------------------
2 files changed, 21 insertions(+), 40 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index a222309..6eee7d6 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1742,30 +1742,25 @@ struct qemud_save_header {
int unused[15];
};
-struct fileOpHookData {
- virDomainPtr dom;
- const char *path;
- char *xml;
- struct qemud_save_header *header;
-};
-
/* return -errno on failure, or 0 on success */
-static int qemudDomainSaveFileOpHook(int fd, void *data) {
- struct fileOpHookData *hdata = data;
+static int
+qemuDomainSaveFileOpHook(int fd, const char *path, char *xml,
+ struct qemud_save_header *header)
+{
int ret = 0;
- if (safewrite(fd, hdata->header, sizeof(*hdata->header)) !=
sizeof(*hdata->header)) {
+ if (safewrite(fd, header, sizeof(*header)) != sizeof(*header)) {
ret = -errno;
qemuReportError(VIR_ERR_OPERATION_FAILED,
_("failed to write header to domain save file
'%s'"),
- hdata->path);
+ path);
goto endjob;
}
- if (safewrite(fd, hdata->xml, hdata->header->xml_len) !=
hdata->header->xml_len) {
+ if (safewrite(fd, xml, header->xml_len) != header->xml_len) {
ret = -errno;
qemuReportError(VIR_ERR_OPERATION_FAILED,
- _("failed to write xml to '%s'"),
hdata->path);
+ _("failed to write xml to '%s'"), path);
goto endjob;
}
endjob:
@@ -1781,7 +1776,6 @@ static int qemudDomainSaveFlag(struct qemud_driver *driver,
virDomainPtr dom,
{
char *xml = NULL;
struct qemud_save_header header;
- struct fileOpHookData hdata;
int bypassSecurityDriver = 0;
int ret = -1;
int rc;
@@ -1947,12 +1941,7 @@ static int qemudDomainSaveFlag(struct qemud_driver *driver,
virDomainPtr dom,
}
/* Write header to file, followed by XML */
- hdata.dom = dom;
- hdata.path = path;
- hdata.xml = xml;
- hdata.header = &header;
-
- if (qemudDomainSaveFileOpHook(fd, &hdata) < 0) {
+ if (qemuDomainSaveFileOpHook(fd, path, xml, &header) < 0) {
VIR_FORCE_CLOSE(fd);
goto endjob;
}
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 5e8d94a..0876cd4 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -266,31 +266,25 @@ cleanup:
return ret;
}
-struct createRawFileOpHookData {
- virStorageVolDefPtr vol;
- virStorageVolDefPtr inputvol;
-};
-
-static int createRawFileOpHook(int fd, void *data) {
- struct createRawFileOpHookData *hdata = data;
+static int createRawFileOpHook(int fd, virStorageVolDefPtr vol,
+ virStorageVolDefPtr inputvol) {
int ret = 0;
unsigned long long remain;
/* Seek to the final size, so the capacity is available upfront
* for progress reporting */
- if (ftruncate(fd, hdata->vol->capacity) < 0) {
+ if (ftruncate(fd, vol->capacity) < 0) {
ret = -errno;
virReportSystemError(errno,
_("cannot extend file '%s'"),
- hdata->vol->target.path);
+ vol->target.path);
goto cleanup;
}
- remain = hdata->vol->allocation;
+ remain = vol->allocation;
- if (hdata->inputvol) {
- ret = virStorageBackendCopyToFD(hdata->vol, hdata->inputvol,
- fd, &remain, 1);
+ if (inputvol) {
+ ret = virStorageBackendCopyToFD(vol, inputvol, fd, &remain, 1);
if (ret < 0) {
goto cleanup;
}
@@ -308,11 +302,10 @@ static int createRawFileOpHook(int fd, void *data) {
if (bytes > remain)
bytes = remain;
- if (safezero(fd, 0, hdata->vol->allocation - remain,
- bytes) != 0) {
+ if (safezero(fd, 0, vol->allocation - remain, bytes) != 0) {
ret = -errno;
virReportSystemError(errno, _("cannot fill file
'%s'"),
- hdata->vol->target.path);
+ vol->target.path);
goto cleanup;
}
remain -= bytes;
@@ -321,7 +314,7 @@ static int createRawFileOpHook(int fd, void *data) {
if (safezero(fd, 0, 0, remain) != 0) {
ret = -errno;
virReportSystemError(errno, _("cannot fill file
'%s'"),
- hdata->vol->target.path);
+ vol->target.path);
goto cleanup;
}
}
@@ -331,7 +324,7 @@ static int createRawFileOpHook(int fd, void *data) {
if (fsync(fd) < 0) {
ret = -errno;
virReportSystemError(errno, _("cannot sync data to file
'%s'"),
- hdata->vol->target.path);
+ vol->target.path);
goto cleanup;
}
@@ -348,7 +341,6 @@ virStorageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UNUSED,
{
int ret = -1;
int fd = -1;
- struct createRawFileOpHookData hdata = { vol, inputvol };
uid_t uid;
gid_t gid;
@@ -377,7 +369,7 @@ virStorageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UNUSED,
goto cleanup;
}
- if ((ret = createRawFileOpHook(fd, &hdata)) < 0) {
+ if ((ret = createRawFileOpHook(fd, vol, inputvol)) < 0) {
virReportSystemError(-fd,
_("cannot create path '%s'"),
vol->target.path);
--
1.7.4