* 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.
---
v5: no real changes
src/qemu/qemu_driver.c | 29 +++++++++--------------------
src/storage/storage_backend.c | 34 ++++++++++++++--------------------
2 files changed, 23 insertions(+), 40 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 8ee2a29..6ecfbd6 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1774,30 +1774,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
+qemuDomainSaveHeader(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:
@@ -1813,7 +1808,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;
@@ -1979,12 +1973,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 (qemuDomainSaveHeader(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 7015475..9b7bcc4 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -292,31 +292,27 @@ cleanup:
return ret;
}
-struct createRawFileOpHookData {
- virStorageVolDefPtr vol;
- virStorageVolDefPtr inputvol;
-};
-
-static int createRawFileOpHook(int fd, void *data) {
- struct createRawFileOpHookData *hdata = data;
+static int
+createRawFile(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;
}
@@ -334,11 +330,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;
@@ -347,7 +342,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;
}
}
@@ -357,7 +352,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;
}
@@ -374,7 +369,6 @@ virStorageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UNUSED,
{
int ret = -1;
int fd = -1;
- struct createRawFileOpHookData hdata = { vol, inputvol };
uid_t uid;
gid_t gid;
int operation_flags;
@@ -404,7 +398,7 @@ virStorageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UNUSED,
goto cleanup;
}
- if ((ret = createRawFileOpHook(fd, &hdata)) < 0) {
+ if ((ret = createRawFile(fd, vol, inputvol)) < 0) {
virReportSystemError(-fd,
_("cannot create path '%s'"),
vol->target.path);
--
1.7.4