提交 261551d1 编写于 作者: L Luiz Capitulino 提交者: Michael Roth

qemu-ga: build_fs_mount_list(): take an Error argument

Signed-off-by: NLuiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
上级 d220a6df
...@@ -371,7 +371,7 @@ static void free_fs_mount_list(FsMountList *mounts) ...@@ -371,7 +371,7 @@ static void free_fs_mount_list(FsMountList *mounts)
/* /*
* Walk the mount table and build a list of local file systems * Walk the mount table and build a list of local file systems
*/ */
static int build_fs_mount_list(FsMountList *mounts) static void build_fs_mount_list(FsMountList *mounts, Error **err)
{ {
struct mntent *ment; struct mntent *ment;
FsMount *mount; FsMount *mount;
...@@ -380,8 +380,8 @@ static int build_fs_mount_list(FsMountList *mounts) ...@@ -380,8 +380,8 @@ static int build_fs_mount_list(FsMountList *mounts)
fp = setmntent(mtab, "r"); fp = setmntent(mtab, "r");
if (!fp) { if (!fp) {
g_warning("fsfreeze: unable to read mtab"); error_setg(err, "failed to open mtab file: '%s'", mtab);
return -1; return;
} }
while ((ment = getmntent(fp))) { while ((ment = getmntent(fp))) {
...@@ -405,8 +405,6 @@ static int build_fs_mount_list(FsMountList *mounts) ...@@ -405,8 +405,6 @@ static int build_fs_mount_list(FsMountList *mounts)
} }
endmntent(fp); endmntent(fp);
return 0;
} }
#endif #endif
...@@ -433,15 +431,17 @@ int64_t qmp_guest_fsfreeze_freeze(Error **err) ...@@ -433,15 +431,17 @@ int64_t qmp_guest_fsfreeze_freeze(Error **err)
int ret = 0, i = 0; int ret = 0, i = 0;
FsMountList mounts; FsMountList mounts;
struct FsMount *mount; struct FsMount *mount;
Error *local_err = NULL;
int fd; int fd;
char err_msg[512]; char err_msg[512];
slog("guest-fsfreeze called"); slog("guest-fsfreeze called");
QTAILQ_INIT(&mounts); QTAILQ_INIT(&mounts);
ret = build_fs_mount_list(&mounts); build_fs_mount_list(&mounts, &local_err);
if (ret < 0) { if (error_is_set(&local_err)) {
return ret; error_propagate(err, local_err);
return -1;
} }
/* cannot risk guest agent blocking itself on a write in this state */ /* cannot risk guest agent blocking itself on a write in this state */
...@@ -498,12 +498,12 @@ int64_t qmp_guest_fsfreeze_thaw(Error **err) ...@@ -498,12 +498,12 @@ int64_t qmp_guest_fsfreeze_thaw(Error **err)
FsMountList mounts; FsMountList mounts;
FsMount *mount; FsMount *mount;
int fd, i = 0, logged; int fd, i = 0, logged;
Error *local_err = NULL;
QTAILQ_INIT(&mounts); QTAILQ_INIT(&mounts);
ret = build_fs_mount_list(&mounts); build_fs_mount_list(&mounts, &local_err);
if (ret) { if (error_is_set(&local_err)) {
error_set(err, QERR_QGA_COMMAND_FAILED, error_propagate(err, local_err);
"failed to enumerate filesystems");
return 0; return 0;
} }
...@@ -568,6 +568,7 @@ void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **err) ...@@ -568,6 +568,7 @@ void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **err)
FsMountList mounts; FsMountList mounts;
struct FsMount *mount; struct FsMount *mount;
int fd; int fd;
Error *local_err = NULL;
char err_msg[512]; char err_msg[512];
struct fstrim_range r = { struct fstrim_range r = {
.start = 0, .start = 0,
...@@ -578,8 +579,9 @@ void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **err) ...@@ -578,8 +579,9 @@ void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **err)
slog("guest-fstrim called"); slog("guest-fstrim called");
QTAILQ_INIT(&mounts); QTAILQ_INIT(&mounts);
ret = build_fs_mount_list(&mounts); build_fs_mount_list(&mounts, &local_err);
if (ret < 0) { if (error_is_set(&local_err)) {
error_propagate(err, local_err);
return; return;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册