qga: Consistently name Error ** objects errp, and not err
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
parent
e940f543ae
commit
77dbc81b0f
@ -53,7 +53,7 @@ extern char **environ;
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void ga_wait_child(pid_t pid, int *status, Error **err)
|
static void ga_wait_child(pid_t pid, int *status, Error **errp)
|
||||||
{
|
{
|
||||||
pid_t rpid;
|
pid_t rpid;
|
||||||
|
|
||||||
@ -64,14 +64,15 @@ static void ga_wait_child(pid_t pid, int *status, Error **err)
|
|||||||
} while (rpid == -1 && errno == EINTR);
|
} while (rpid == -1 && errno == EINTR);
|
||||||
|
|
||||||
if (rpid == -1) {
|
if (rpid == -1) {
|
||||||
error_setg_errno(err, errno, "failed to wait for child (pid: %d)", pid);
|
error_setg_errno(errp, errno, "failed to wait for child (pid: %d)",
|
||||||
|
pid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_assert(rpid == pid);
|
g_assert(rpid == pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void qmp_guest_shutdown(bool has_mode, const char *mode, Error **err)
|
void qmp_guest_shutdown(bool has_mode, const char *mode, Error **errp)
|
||||||
{
|
{
|
||||||
const char *shutdown_flag;
|
const char *shutdown_flag;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
@ -86,7 +87,7 @@ void qmp_guest_shutdown(bool has_mode, const char *mode, Error **err)
|
|||||||
} else if (strcmp(mode, "reboot") == 0) {
|
} else if (strcmp(mode, "reboot") == 0) {
|
||||||
shutdown_flag = "-r";
|
shutdown_flag = "-r";
|
||||||
} else {
|
} else {
|
||||||
error_setg(err,
|
error_setg(errp,
|
||||||
"mode is invalid (valid values are: halt|powerdown|reboot");
|
"mode is invalid (valid values are: halt|powerdown|reboot");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -103,23 +104,23 @@ void qmp_guest_shutdown(bool has_mode, const char *mode, Error **err)
|
|||||||
"hypervisor initiated shutdown", (char*)NULL, environ);
|
"hypervisor initiated shutdown", (char*)NULL, environ);
|
||||||
_exit(EXIT_FAILURE);
|
_exit(EXIT_FAILURE);
|
||||||
} else if (pid < 0) {
|
} else if (pid < 0) {
|
||||||
error_setg_errno(err, errno, "failed to create child process");
|
error_setg_errno(errp, errno, "failed to create child process");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ga_wait_child(pid, &status, &local_err);
|
ga_wait_child(pid, &status, &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
error_propagate(err, local_err);
|
error_propagate(errp, local_err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!WIFEXITED(status)) {
|
if (!WIFEXITED(status)) {
|
||||||
error_setg(err, "child process has terminated abnormally");
|
error_setg(errp, "child process has terminated abnormally");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WEXITSTATUS(status)) {
|
if (WEXITSTATUS(status)) {
|
||||||
error_setg(err, "child process has failed to shutdown");
|
error_setg(errp, "child process has failed to shutdown");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,7 +235,7 @@ static int64_t guest_file_handle_add(FILE *fh, Error **errp)
|
|||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GuestFileHandle *guest_file_handle_find(int64_t id, Error **err)
|
static GuestFileHandle *guest_file_handle_find(int64_t id, Error **errp)
|
||||||
{
|
{
|
||||||
GuestFileHandle *gfh;
|
GuestFileHandle *gfh;
|
||||||
|
|
||||||
@ -245,7 +246,7 @@ static GuestFileHandle *guest_file_handle_find(int64_t id, Error **err)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
error_setg(err, "handle '%" PRId64 "' has not been found", id);
|
error_setg(errp, "handle '%" PRId64 "' has not been found", id);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,7 +276,7 @@ static const struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
find_open_flag(const char *mode_str, Error **err)
|
find_open_flag(const char *mode_str, Error **errp)
|
||||||
{
|
{
|
||||||
unsigned mode;
|
unsigned mode;
|
||||||
|
|
||||||
@ -292,7 +293,7 @@ find_open_flag(const char *mode_str, Error **err)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mode == ARRAY_SIZE(guest_file_open_modes)) {
|
if (mode == ARRAY_SIZE(guest_file_open_modes)) {
|
||||||
error_setg(err, "invalid file open mode '%s'", mode_str);
|
error_setg(errp, "invalid file open mode '%s'", mode_str);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return guest_file_open_modes[mode].oflag_base | O_NOCTTY | O_NONBLOCK;
|
return guest_file_open_modes[mode].oflag_base | O_NOCTTY | O_NONBLOCK;
|
||||||
@ -303,7 +304,7 @@ find_open_flag(const char *mode_str, Error **err)
|
|||||||
S_IROTH | S_IWOTH)
|
S_IROTH | S_IWOTH)
|
||||||
|
|
||||||
static FILE *
|
static FILE *
|
||||||
safe_open_or_create(const char *path, const char *mode, Error **err)
|
safe_open_or_create(const char *path, const char *mode, Error **errp)
|
||||||
{
|
{
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
int oflag;
|
int oflag;
|
||||||
@ -370,11 +371,12 @@ safe_open_or_create(const char *path, const char *mode, Error **err)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
error_propagate(err, local_err);
|
error_propagate(errp, local_err);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode, Error **err)
|
int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode,
|
||||||
|
Error **errp)
|
||||||
{
|
{
|
||||||
FILE *fh;
|
FILE *fh;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
@ -387,7 +389,7 @@ int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode, E
|
|||||||
slog("guest-file-open called, filepath: %s, mode: %s", path, mode);
|
slog("guest-file-open called, filepath: %s, mode: %s", path, mode);
|
||||||
fh = safe_open_or_create(path, mode, &local_err);
|
fh = safe_open_or_create(path, mode, &local_err);
|
||||||
if (local_err != NULL) {
|
if (local_err != NULL) {
|
||||||
error_propagate(err, local_err);
|
error_propagate(errp, local_err);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,14 +400,14 @@ int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode, E
|
|||||||
ret = fcntl(fd, F_GETFL);
|
ret = fcntl(fd, F_GETFL);
|
||||||
ret = fcntl(fd, F_SETFL, ret | O_NONBLOCK);
|
ret = fcntl(fd, F_SETFL, ret | O_NONBLOCK);
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
error_setg_errno(err, errno, "failed to make file '%s' non-blocking",
|
error_setg_errno(errp, errno, "failed to make file '%s' non-blocking",
|
||||||
path);
|
path);
|
||||||
fclose(fh);
|
fclose(fh);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle = guest_file_handle_add(fh, err);
|
handle = guest_file_handle_add(fh, errp);
|
||||||
if (error_is_set(err)) {
|
if (error_is_set(errp)) {
|
||||||
fclose(fh);
|
fclose(fh);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -414,9 +416,9 @@ int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode, E
|
|||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qmp_guest_file_close(int64_t handle, Error **err)
|
void qmp_guest_file_close(int64_t handle, Error **errp)
|
||||||
{
|
{
|
||||||
GuestFileHandle *gfh = guest_file_handle_find(handle, err);
|
GuestFileHandle *gfh = guest_file_handle_find(handle, errp);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
slog("guest-file-close called, handle: %" PRId64, handle);
|
slog("guest-file-close called, handle: %" PRId64, handle);
|
||||||
@ -426,7 +428,7 @@ void qmp_guest_file_close(int64_t handle, Error **err)
|
|||||||
|
|
||||||
ret = fclose(gfh->fh);
|
ret = fclose(gfh->fh);
|
||||||
if (ret == EOF) {
|
if (ret == EOF) {
|
||||||
error_setg_errno(err, errno, "failed to close handle");
|
error_setg_errno(errp, errno, "failed to close handle");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,9 +437,9 @@ void qmp_guest_file_close(int64_t handle, Error **err)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count,
|
struct GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count,
|
||||||
int64_t count, Error **err)
|
int64_t count, Error **errp)
|
||||||
{
|
{
|
||||||
GuestFileHandle *gfh = guest_file_handle_find(handle, err);
|
GuestFileHandle *gfh = guest_file_handle_find(handle, errp);
|
||||||
GuestFileRead *read_data = NULL;
|
GuestFileRead *read_data = NULL;
|
||||||
guchar *buf;
|
guchar *buf;
|
||||||
FILE *fh;
|
FILE *fh;
|
||||||
@ -450,7 +452,7 @@ struct GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count,
|
|||||||
if (!has_count) {
|
if (!has_count) {
|
||||||
count = QGA_READ_COUNT_DEFAULT;
|
count = QGA_READ_COUNT_DEFAULT;
|
||||||
} else if (count < 0) {
|
} else if (count < 0) {
|
||||||
error_setg(err, "value '%" PRId64 "' is invalid for argument count",
|
error_setg(errp, "value '%" PRId64 "' is invalid for argument count",
|
||||||
count);
|
count);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -459,7 +461,7 @@ struct GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count,
|
|||||||
buf = g_malloc0(count+1);
|
buf = g_malloc0(count+1);
|
||||||
read_count = fread(buf, 1, count, fh);
|
read_count = fread(buf, 1, count, fh);
|
||||||
if (ferror(fh)) {
|
if (ferror(fh)) {
|
||||||
error_setg_errno(err, errno, "failed to read file");
|
error_setg_errno(errp, errno, "failed to read file");
|
||||||
slog("guest-file-read failed, handle: %" PRId64, handle);
|
slog("guest-file-read failed, handle: %" PRId64, handle);
|
||||||
} else {
|
} else {
|
||||||
buf[read_count] = 0;
|
buf[read_count] = 0;
|
||||||
@ -477,13 +479,14 @@ struct GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count,
|
|||||||
}
|
}
|
||||||
|
|
||||||
GuestFileWrite *qmp_guest_file_write(int64_t handle, const char *buf_b64,
|
GuestFileWrite *qmp_guest_file_write(int64_t handle, const char *buf_b64,
|
||||||
bool has_count, int64_t count, Error **err)
|
bool has_count, int64_t count,
|
||||||
|
Error **errp)
|
||||||
{
|
{
|
||||||
GuestFileWrite *write_data = NULL;
|
GuestFileWrite *write_data = NULL;
|
||||||
guchar *buf;
|
guchar *buf;
|
||||||
gsize buf_len;
|
gsize buf_len;
|
||||||
int write_count;
|
int write_count;
|
||||||
GuestFileHandle *gfh = guest_file_handle_find(handle, err);
|
GuestFileHandle *gfh = guest_file_handle_find(handle, errp);
|
||||||
FILE *fh;
|
FILE *fh;
|
||||||
|
|
||||||
if (!gfh) {
|
if (!gfh) {
|
||||||
@ -496,7 +499,7 @@ GuestFileWrite *qmp_guest_file_write(int64_t handle, const char *buf_b64,
|
|||||||
if (!has_count) {
|
if (!has_count) {
|
||||||
count = buf_len;
|
count = buf_len;
|
||||||
} else if (count < 0 || count > buf_len) {
|
} else if (count < 0 || count > buf_len) {
|
||||||
error_setg(err, "value '%" PRId64 "' is invalid for argument count",
|
error_setg(errp, "value '%" PRId64 "' is invalid for argument count",
|
||||||
count);
|
count);
|
||||||
g_free(buf);
|
g_free(buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -504,7 +507,7 @@ GuestFileWrite *qmp_guest_file_write(int64_t handle, const char *buf_b64,
|
|||||||
|
|
||||||
write_count = fwrite(buf, 1, count, fh);
|
write_count = fwrite(buf, 1, count, fh);
|
||||||
if (ferror(fh)) {
|
if (ferror(fh)) {
|
||||||
error_setg_errno(err, errno, "failed to write to file");
|
error_setg_errno(errp, errno, "failed to write to file");
|
||||||
slog("guest-file-write failed, handle: %" PRId64, handle);
|
slog("guest-file-write failed, handle: %" PRId64, handle);
|
||||||
} else {
|
} else {
|
||||||
write_data = g_malloc0(sizeof(GuestFileWrite));
|
write_data = g_malloc0(sizeof(GuestFileWrite));
|
||||||
@ -518,9 +521,9 @@ GuestFileWrite *qmp_guest_file_write(int64_t handle, const char *buf_b64,
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct GuestFileSeek *qmp_guest_file_seek(int64_t handle, int64_t offset,
|
struct GuestFileSeek *qmp_guest_file_seek(int64_t handle, int64_t offset,
|
||||||
int64_t whence, Error **err)
|
int64_t whence, Error **errp)
|
||||||
{
|
{
|
||||||
GuestFileHandle *gfh = guest_file_handle_find(handle, err);
|
GuestFileHandle *gfh = guest_file_handle_find(handle, errp);
|
||||||
GuestFileSeek *seek_data = NULL;
|
GuestFileSeek *seek_data = NULL;
|
||||||
FILE *fh;
|
FILE *fh;
|
||||||
int ret;
|
int ret;
|
||||||
@ -532,7 +535,7 @@ struct GuestFileSeek *qmp_guest_file_seek(int64_t handle, int64_t offset,
|
|||||||
fh = gfh->fh;
|
fh = gfh->fh;
|
||||||
ret = fseek(fh, offset, whence);
|
ret = fseek(fh, offset, whence);
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
error_setg_errno(err, errno, "failed to seek file");
|
error_setg_errno(errp, errno, "failed to seek file");
|
||||||
} else {
|
} else {
|
||||||
seek_data = g_new0(GuestFileSeek, 1);
|
seek_data = g_new0(GuestFileSeek, 1);
|
||||||
seek_data->position = ftell(fh);
|
seek_data->position = ftell(fh);
|
||||||
@ -543,9 +546,9 @@ struct GuestFileSeek *qmp_guest_file_seek(int64_t handle, int64_t offset,
|
|||||||
return seek_data;
|
return seek_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qmp_guest_file_flush(int64_t handle, Error **err)
|
void qmp_guest_file_flush(int64_t handle, Error **errp)
|
||||||
{
|
{
|
||||||
GuestFileHandle *gfh = guest_file_handle_find(handle, err);
|
GuestFileHandle *gfh = guest_file_handle_find(handle, errp);
|
||||||
FILE *fh;
|
FILE *fh;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -556,7 +559,7 @@ void qmp_guest_file_flush(int64_t handle, Error **err)
|
|||||||
fh = gfh->fh;
|
fh = gfh->fh;
|
||||||
ret = fflush(fh);
|
ret = fflush(fh);
|
||||||
if (ret == EOF) {
|
if (ret == EOF) {
|
||||||
error_setg_errno(err, errno, "failed to flush file");
|
error_setg_errno(errp, errno, "failed to flush file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -596,7 +599,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 void build_fs_mount_list(FsMountList *mounts, Error **err)
|
static void build_fs_mount_list(FsMountList *mounts, Error **errp)
|
||||||
{
|
{
|
||||||
struct mntent *ment;
|
struct mntent *ment;
|
||||||
FsMount *mount;
|
FsMount *mount;
|
||||||
@ -605,7 +608,7 @@ static void build_fs_mount_list(FsMountList *mounts, Error **err)
|
|||||||
|
|
||||||
fp = setmntent(mtab, "r");
|
fp = setmntent(mtab, "r");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
error_setg(err, "failed to open mtab file: '%s'", mtab);
|
error_setg(errp, "failed to open mtab file: '%s'", mtab);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -645,7 +648,7 @@ const char *fsfreeze_hook_arg_string[] = {
|
|||||||
"freeze",
|
"freeze",
|
||||||
};
|
};
|
||||||
|
|
||||||
static void execute_fsfreeze_hook(FsfreezeHookArg arg, Error **err)
|
static void execute_fsfreeze_hook(FsfreezeHookArg arg, Error **errp)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
@ -658,7 +661,7 @@ static void execute_fsfreeze_hook(FsfreezeHookArg arg, Error **err)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (access(hook, X_OK) != 0) {
|
if (access(hook, X_OK) != 0) {
|
||||||
error_setg_errno(err, errno, "can't access fsfreeze hook '%s'", hook);
|
error_setg_errno(errp, errno, "can't access fsfreeze hook '%s'", hook);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -673,24 +676,24 @@ static void execute_fsfreeze_hook(FsfreezeHookArg arg, Error **err)
|
|||||||
execle(hook, hook, arg_str, NULL, environ);
|
execle(hook, hook, arg_str, NULL, environ);
|
||||||
_exit(EXIT_FAILURE);
|
_exit(EXIT_FAILURE);
|
||||||
} else if (pid < 0) {
|
} else if (pid < 0) {
|
||||||
error_setg_errno(err, errno, "failed to create child process");
|
error_setg_errno(errp, errno, "failed to create child process");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ga_wait_child(pid, &status, &local_err);
|
ga_wait_child(pid, &status, &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
error_propagate(err, local_err);
|
error_propagate(errp, local_err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!WIFEXITED(status)) {
|
if (!WIFEXITED(status)) {
|
||||||
error_setg(err, "fsfreeze hook has terminated abnormally");
|
error_setg(errp, "fsfreeze hook has terminated abnormally");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = WEXITSTATUS(status);
|
status = WEXITSTATUS(status);
|
||||||
if (status) {
|
if (status) {
|
||||||
error_setg(err, "fsfreeze hook has failed with status %d", status);
|
error_setg(errp, "fsfreeze hook has failed with status %d", status);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -698,7 +701,7 @@ static void execute_fsfreeze_hook(FsfreezeHookArg arg, Error **err)
|
|||||||
/*
|
/*
|
||||||
* Return status of freeze/thaw
|
* Return status of freeze/thaw
|
||||||
*/
|
*/
|
||||||
GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **err)
|
GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **errp)
|
||||||
{
|
{
|
||||||
if (ga_is_frozen(ga_state)) {
|
if (ga_is_frozen(ga_state)) {
|
||||||
return GUEST_FSFREEZE_STATUS_FROZEN;
|
return GUEST_FSFREEZE_STATUS_FROZEN;
|
||||||
@ -711,7 +714,7 @@ GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **err)
|
|||||||
* Walk list of mounted file systems in the guest, and freeze the ones which
|
* Walk list of mounted file systems in the guest, and freeze the ones which
|
||||||
* are real local file systems.
|
* are real local file systems.
|
||||||
*/
|
*/
|
||||||
int64_t qmp_guest_fsfreeze_freeze(Error **err)
|
int64_t qmp_guest_fsfreeze_freeze(Error **errp)
|
||||||
{
|
{
|
||||||
int ret = 0, i = 0;
|
int ret = 0, i = 0;
|
||||||
FsMountList mounts;
|
FsMountList mounts;
|
||||||
@ -723,14 +726,14 @@ int64_t qmp_guest_fsfreeze_freeze(Error **err)
|
|||||||
|
|
||||||
execute_fsfreeze_hook(FSFREEZE_HOOK_FREEZE, &local_err);
|
execute_fsfreeze_hook(FSFREEZE_HOOK_FREEZE, &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
error_propagate(err, local_err);
|
error_propagate(errp, local_err);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTAILQ_INIT(&mounts);
|
QTAILQ_INIT(&mounts);
|
||||||
build_fs_mount_list(&mounts, &local_err);
|
build_fs_mount_list(&mounts, &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
error_propagate(err, local_err);
|
error_propagate(errp, local_err);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -740,7 +743,7 @@ int64_t qmp_guest_fsfreeze_freeze(Error **err)
|
|||||||
QTAILQ_FOREACH_REVERSE(mount, &mounts, FsMountList, next) {
|
QTAILQ_FOREACH_REVERSE(mount, &mounts, FsMountList, next) {
|
||||||
fd = qemu_open(mount->dirname, O_RDONLY);
|
fd = qemu_open(mount->dirname, O_RDONLY);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
error_setg_errno(err, errno, "failed to open %s", mount->dirname);
|
error_setg_errno(errp, errno, "failed to open %s", mount->dirname);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -756,7 +759,7 @@ int64_t qmp_guest_fsfreeze_freeze(Error **err)
|
|||||||
ret = ioctl(fd, FIFREEZE);
|
ret = ioctl(fd, FIFREEZE);
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
if (errno != EOPNOTSUPP) {
|
if (errno != EOPNOTSUPP) {
|
||||||
error_setg_errno(err, errno, "failed to freeze %s",
|
error_setg_errno(errp, errno, "failed to freeze %s",
|
||||||
mount->dirname);
|
mount->dirname);
|
||||||
close(fd);
|
close(fd);
|
||||||
goto error;
|
goto error;
|
||||||
@ -779,7 +782,7 @@ error:
|
|||||||
/*
|
/*
|
||||||
* Walk list of frozen file systems in the guest, and thaw them.
|
* Walk list of frozen file systems in the guest, and thaw them.
|
||||||
*/
|
*/
|
||||||
int64_t qmp_guest_fsfreeze_thaw(Error **err)
|
int64_t qmp_guest_fsfreeze_thaw(Error **errp)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
FsMountList mounts;
|
FsMountList mounts;
|
||||||
@ -790,7 +793,7 @@ int64_t qmp_guest_fsfreeze_thaw(Error **err)
|
|||||||
QTAILQ_INIT(&mounts);
|
QTAILQ_INIT(&mounts);
|
||||||
build_fs_mount_list(&mounts, &local_err);
|
build_fs_mount_list(&mounts, &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
error_propagate(err, local_err);
|
error_propagate(errp, local_err);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -829,7 +832,7 @@ int64_t qmp_guest_fsfreeze_thaw(Error **err)
|
|||||||
ga_unset_frozen(ga_state);
|
ga_unset_frozen(ga_state);
|
||||||
free_fs_mount_list(&mounts);
|
free_fs_mount_list(&mounts);
|
||||||
|
|
||||||
execute_fsfreeze_hook(FSFREEZE_HOOK_THAW, err);
|
execute_fsfreeze_hook(FSFREEZE_HOOK_THAW, errp);
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@ -853,7 +856,7 @@ static void guest_fsfreeze_cleanup(void)
|
|||||||
/*
|
/*
|
||||||
* Walk list of mounted file systems in the guest, and trim them.
|
* Walk list of mounted file systems in the guest, and trim them.
|
||||||
*/
|
*/
|
||||||
void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **err)
|
void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
FsMountList mounts;
|
FsMountList mounts;
|
||||||
@ -871,14 +874,14 @@ void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **err)
|
|||||||
QTAILQ_INIT(&mounts);
|
QTAILQ_INIT(&mounts);
|
||||||
build_fs_mount_list(&mounts, &local_err);
|
build_fs_mount_list(&mounts, &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
error_propagate(err, local_err);
|
error_propagate(errp, local_err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTAILQ_FOREACH(mount, &mounts, next) {
|
QTAILQ_FOREACH(mount, &mounts, next) {
|
||||||
fd = qemu_open(mount->dirname, O_RDONLY);
|
fd = qemu_open(mount->dirname, O_RDONLY);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
error_setg_errno(err, errno, "failed to open %s", mount->dirname);
|
error_setg_errno(errp, errno, "failed to open %s", mount->dirname);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -891,7 +894,7 @@ void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **err)
|
|||||||
ret = ioctl(fd, FITRIM, &r);
|
ret = ioctl(fd, FITRIM, &r);
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
if (errno != ENOTTY && errno != EOPNOTSUPP) {
|
if (errno != ENOTTY && errno != EOPNOTSUPP) {
|
||||||
error_setg_errno(err, errno, "failed to trim %s",
|
error_setg_errno(errp, errno, "failed to trim %s",
|
||||||
mount->dirname);
|
mount->dirname);
|
||||||
close(fd);
|
close(fd);
|
||||||
goto error;
|
goto error;
|
||||||
@ -911,7 +914,7 @@ error:
|
|||||||
#define SUSPEND_NOT_SUPPORTED 1
|
#define SUSPEND_NOT_SUPPORTED 1
|
||||||
|
|
||||||
static void bios_supports_mode(const char *pmutils_bin, const char *pmutils_arg,
|
static void bios_supports_mode(const char *pmutils_bin, const char *pmutils_arg,
|
||||||
const char *sysfile_str, Error **err)
|
const char *sysfile_str, Error **errp)
|
||||||
{
|
{
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
char *pmutils_path;
|
char *pmutils_path;
|
||||||
@ -961,18 +964,18 @@ static void bios_supports_mode(const char *pmutils_bin, const char *pmutils_arg,
|
|||||||
|
|
||||||
_exit(SUSPEND_NOT_SUPPORTED);
|
_exit(SUSPEND_NOT_SUPPORTED);
|
||||||
} else if (pid < 0) {
|
} else if (pid < 0) {
|
||||||
error_setg_errno(err, errno, "failed to create child process");
|
error_setg_errno(errp, errno, "failed to create child process");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ga_wait_child(pid, &status, &local_err);
|
ga_wait_child(pid, &status, &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
error_propagate(err, local_err);
|
error_propagate(errp, local_err);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!WIFEXITED(status)) {
|
if (!WIFEXITED(status)) {
|
||||||
error_setg(err, "child process has terminated abnormally");
|
error_setg(errp, "child process has terminated abnormally");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -980,11 +983,11 @@ static void bios_supports_mode(const char *pmutils_bin, const char *pmutils_arg,
|
|||||||
case SUSPEND_SUPPORTED:
|
case SUSPEND_SUPPORTED:
|
||||||
goto out;
|
goto out;
|
||||||
case SUSPEND_NOT_SUPPORTED:
|
case SUSPEND_NOT_SUPPORTED:
|
||||||
error_setg(err,
|
error_setg(errp,
|
||||||
"the requested suspend mode is not supported by the guest");
|
"the requested suspend mode is not supported by the guest");
|
||||||
goto out;
|
goto out;
|
||||||
default:
|
default:
|
||||||
error_setg(err,
|
error_setg(errp,
|
||||||
"the helper program '%s' returned an unexpected exit status"
|
"the helper program '%s' returned an unexpected exit status"
|
||||||
" code (%d)", pmutils_path, WEXITSTATUS(status));
|
" code (%d)", pmutils_path, WEXITSTATUS(status));
|
||||||
goto out;
|
goto out;
|
||||||
@ -995,7 +998,7 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void guest_suspend(const char *pmutils_bin, const char *sysfile_str,
|
static void guest_suspend(const char *pmutils_bin, const char *sysfile_str,
|
||||||
Error **err)
|
Error **errp)
|
||||||
{
|
{
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
char *pmutils_path;
|
char *pmutils_path;
|
||||||
@ -1038,23 +1041,23 @@ static void guest_suspend(const char *pmutils_bin, const char *sysfile_str,
|
|||||||
|
|
||||||
_exit(EXIT_SUCCESS);
|
_exit(EXIT_SUCCESS);
|
||||||
} else if (pid < 0) {
|
} else if (pid < 0) {
|
||||||
error_setg_errno(err, errno, "failed to create child process");
|
error_setg_errno(errp, errno, "failed to create child process");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ga_wait_child(pid, &status, &local_err);
|
ga_wait_child(pid, &status, &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
error_propagate(err, local_err);
|
error_propagate(errp, local_err);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!WIFEXITED(status)) {
|
if (!WIFEXITED(status)) {
|
||||||
error_setg(err, "child process has terminated abnormally");
|
error_setg(errp, "child process has terminated abnormally");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WEXITSTATUS(status)) {
|
if (WEXITSTATUS(status)) {
|
||||||
error_setg(err, "child process has failed to suspend");
|
error_setg(errp, "child process has failed to suspend");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1062,34 +1065,34 @@ out:
|
|||||||
g_free(pmutils_path);
|
g_free(pmutils_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void qmp_guest_suspend_disk(Error **err)
|
void qmp_guest_suspend_disk(Error **errp)
|
||||||
{
|
{
|
||||||
bios_supports_mode("pm-is-supported", "--hibernate", "disk", err);
|
bios_supports_mode("pm-is-supported", "--hibernate", "disk", errp);
|
||||||
if (error_is_set(err)) {
|
if (error_is_set(errp)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
guest_suspend("pm-hibernate", "disk", err);
|
guest_suspend("pm-hibernate", "disk", errp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void qmp_guest_suspend_ram(Error **err)
|
void qmp_guest_suspend_ram(Error **errp)
|
||||||
{
|
{
|
||||||
bios_supports_mode("pm-is-supported", "--suspend", "mem", err);
|
bios_supports_mode("pm-is-supported", "--suspend", "mem", errp);
|
||||||
if (error_is_set(err)) {
|
if (error_is_set(errp)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
guest_suspend("pm-suspend", "mem", err);
|
guest_suspend("pm-suspend", "mem", errp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void qmp_guest_suspend_hybrid(Error **err)
|
void qmp_guest_suspend_hybrid(Error **errp)
|
||||||
{
|
{
|
||||||
bios_supports_mode("pm-is-supported", "--suspend-hybrid", NULL, err);
|
bios_supports_mode("pm-is-supported", "--suspend-hybrid", NULL, errp);
|
||||||
if (error_is_set(err)) {
|
if (error_is_set(errp)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
guest_suspend("pm-suspend-hybrid", NULL, err);
|
guest_suspend("pm-suspend-hybrid", NULL, errp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GuestNetworkInterfaceList *
|
static GuestNetworkInterfaceList *
|
||||||
@ -1252,9 +1255,9 @@ error:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SYSCONF_EXACT(name, err) sysconf_exact((name), #name, (err))
|
#define SYSCONF_EXACT(name, errp) sysconf_exact((name), #name, (errp))
|
||||||
|
|
||||||
static long sysconf_exact(int name, const char *name_str, Error **err)
|
static long sysconf_exact(int name, const char *name_str, Error **errp)
|
||||||
{
|
{
|
||||||
long ret;
|
long ret;
|
||||||
|
|
||||||
@ -1262,9 +1265,9 @@ static long sysconf_exact(int name, const char *name_str, Error **err)
|
|||||||
ret = sysconf(name);
|
ret = sysconf(name);
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
if (errno == 0) {
|
if (errno == 0) {
|
||||||
error_setg(err, "sysconf(%s): value indefinite", name_str);
|
error_setg(errp, "sysconf(%s): value indefinite", name_str);
|
||||||
} else {
|
} else {
|
||||||
error_setg_errno(err, errno, "sysconf(%s)", name_str);
|
error_setg_errno(errp, errno, "sysconf(%s)", name_str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -1410,19 +1413,19 @@ int64_t qmp_guest_set_vcpus(GuestLogicalProcessorList *vcpus, Error **errp)
|
|||||||
|
|
||||||
#else /* defined(__linux__) */
|
#else /* defined(__linux__) */
|
||||||
|
|
||||||
void qmp_guest_suspend_disk(Error **err)
|
void qmp_guest_suspend_disk(Error **errp)
|
||||||
{
|
{
|
||||||
error_set(err, QERR_UNSUPPORTED);
|
error_set(errp, QERR_UNSUPPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void qmp_guest_suspend_ram(Error **err)
|
void qmp_guest_suspend_ram(Error **errp)
|
||||||
{
|
{
|
||||||
error_set(err, QERR_UNSUPPORTED);
|
error_set(errp, QERR_UNSUPPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void qmp_guest_suspend_hybrid(Error **err)
|
void qmp_guest_suspend_hybrid(Error **errp)
|
||||||
{
|
{
|
||||||
error_set(err, QERR_UNSUPPORTED);
|
error_set(errp, QERR_UNSUPPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp)
|
GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp)
|
||||||
@ -1447,32 +1450,32 @@ int64_t qmp_guest_set_vcpus(GuestLogicalProcessorList *vcpus, Error **errp)
|
|||||||
|
|
||||||
#if !defined(CONFIG_FSFREEZE)
|
#if !defined(CONFIG_FSFREEZE)
|
||||||
|
|
||||||
GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **err)
|
GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **errp)
|
||||||
{
|
{
|
||||||
error_set(err, QERR_UNSUPPORTED);
|
error_set(errp, QERR_UNSUPPORTED);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t qmp_guest_fsfreeze_freeze(Error **err)
|
int64_t qmp_guest_fsfreeze_freeze(Error **errp)
|
||||||
{
|
{
|
||||||
error_set(err, QERR_UNSUPPORTED);
|
error_set(errp, QERR_UNSUPPORTED);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t qmp_guest_fsfreeze_thaw(Error **err)
|
int64_t qmp_guest_fsfreeze_thaw(Error **errp)
|
||||||
{
|
{
|
||||||
error_set(err, QERR_UNSUPPORTED);
|
error_set(errp, QERR_UNSUPPORTED);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_FSFREEZE */
|
#endif /* CONFIG_FSFREEZE */
|
||||||
|
|
||||||
#if !defined(CONFIG_FSTRIM)
|
#if !defined(CONFIG_FSTRIM)
|
||||||
void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **err)
|
void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
|
||||||
{
|
{
|
||||||
error_set(err, QERR_UNSUPPORTED);
|
error_set(errp, QERR_UNSUPPORTED);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -29,13 +29,13 @@
|
|||||||
(365 * (1970 - 1601) + \
|
(365 * (1970 - 1601) + \
|
||||||
(1970 - 1601) / 4 - 3))
|
(1970 - 1601) / 4 - 3))
|
||||||
|
|
||||||
static void acquire_privilege(const char *name, Error **err)
|
static void acquire_privilege(const char *name, Error **errp)
|
||||||
{
|
{
|
||||||
HANDLE token;
|
HANDLE token;
|
||||||
TOKEN_PRIVILEGES priv;
|
TOKEN_PRIVILEGES priv;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
|
|
||||||
if (error_is_set(err)) {
|
if (error_is_set(errp)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,26 +65,27 @@ static void acquire_privilege(const char *name, Error **err)
|
|||||||
|
|
||||||
out:
|
out:
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
error_propagate(err, local_err);
|
error_propagate(errp, local_err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void execute_async(DWORD WINAPI (*func)(LPVOID), LPVOID opaque, Error **err)
|
static void execute_async(DWORD WINAPI (*func)(LPVOID), LPVOID opaque,
|
||||||
|
Error **errp)
|
||||||
{
|
{
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
|
|
||||||
if (error_is_set(err)) {
|
if (error_is_set(errp)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
HANDLE thread = CreateThread(NULL, 0, func, opaque, 0, NULL);
|
HANDLE thread = CreateThread(NULL, 0, func, opaque, 0, NULL);
|
||||||
if (!thread) {
|
if (!thread) {
|
||||||
error_set(&local_err, QERR_QGA_COMMAND_FAILED,
|
error_set(&local_err, QERR_QGA_COMMAND_FAILED,
|
||||||
"failed to dispatch asynchronous command");
|
"failed to dispatch asynchronous command");
|
||||||
error_propagate(err, local_err);
|
error_propagate(errp, local_err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void qmp_guest_shutdown(bool has_mode, const char *mode, Error **err)
|
void qmp_guest_shutdown(bool has_mode, const char *mode, Error **errp)
|
||||||
{
|
{
|
||||||
UINT shutdown_flag = EWX_FORCE;
|
UINT shutdown_flag = EWX_FORCE;
|
||||||
|
|
||||||
@ -97,68 +98,70 @@ void qmp_guest_shutdown(bool has_mode, const char *mode, Error **err)
|
|||||||
} else if (strcmp(mode, "reboot") == 0) {
|
} else if (strcmp(mode, "reboot") == 0) {
|
||||||
shutdown_flag |= EWX_REBOOT;
|
shutdown_flag |= EWX_REBOOT;
|
||||||
} else {
|
} else {
|
||||||
error_set(err, QERR_INVALID_PARAMETER_VALUE, "mode",
|
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "mode",
|
||||||
"halt|powerdown|reboot");
|
"halt|powerdown|reboot");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Request a shutdown privilege, but try to shut down the system
|
/* Request a shutdown privilege, but try to shut down the system
|
||||||
anyway. */
|
anyway. */
|
||||||
acquire_privilege(SE_SHUTDOWN_NAME, err);
|
acquire_privilege(SE_SHUTDOWN_NAME, errp);
|
||||||
if (error_is_set(err)) {
|
if (error_is_set(errp)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ExitWindowsEx(shutdown_flag, SHTDN_REASON_FLAG_PLANNED)) {
|
if (!ExitWindowsEx(shutdown_flag, SHTDN_REASON_FLAG_PLANNED)) {
|
||||||
slog("guest-shutdown failed: %lu", GetLastError());
|
slog("guest-shutdown failed: %lu", GetLastError());
|
||||||
error_set(err, QERR_UNDEFINED_ERROR);
|
error_set(errp, QERR_UNDEFINED_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode, Error **err)
|
int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode,
|
||||||
|
Error **errp)
|
||||||
{
|
{
|
||||||
error_set(err, QERR_UNSUPPORTED);
|
error_set(errp, QERR_UNSUPPORTED);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qmp_guest_file_close(int64_t handle, Error **err)
|
void qmp_guest_file_close(int64_t handle, Error **errp)
|
||||||
{
|
{
|
||||||
error_set(err, QERR_UNSUPPORTED);
|
error_set(errp, QERR_UNSUPPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count,
|
GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count,
|
||||||
int64_t count, Error **err)
|
int64_t count, Error **errp)
|
||||||
{
|
{
|
||||||
error_set(err, QERR_UNSUPPORTED);
|
error_set(errp, QERR_UNSUPPORTED);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
GuestFileWrite *qmp_guest_file_write(int64_t handle, const char *buf_b64,
|
GuestFileWrite *qmp_guest_file_write(int64_t handle, const char *buf_b64,
|
||||||
bool has_count, int64_t count, Error **err)
|
bool has_count, int64_t count,
|
||||||
|
Error **errp)
|
||||||
{
|
{
|
||||||
error_set(err, QERR_UNSUPPORTED);
|
error_set(errp, QERR_UNSUPPORTED);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
GuestFileSeek *qmp_guest_file_seek(int64_t handle, int64_t offset,
|
GuestFileSeek *qmp_guest_file_seek(int64_t handle, int64_t offset,
|
||||||
int64_t whence, Error **err)
|
int64_t whence, Error **errp)
|
||||||
{
|
{
|
||||||
error_set(err, QERR_UNSUPPORTED);
|
error_set(errp, QERR_UNSUPPORTED);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qmp_guest_file_flush(int64_t handle, Error **err)
|
void qmp_guest_file_flush(int64_t handle, Error **errp)
|
||||||
{
|
{
|
||||||
error_set(err, QERR_UNSUPPORTED);
|
error_set(errp, QERR_UNSUPPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return status of freeze/thaw
|
* Return status of freeze/thaw
|
||||||
*/
|
*/
|
||||||
GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **err)
|
GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **errp)
|
||||||
{
|
{
|
||||||
if (!vss_initialized()) {
|
if (!vss_initialized()) {
|
||||||
error_set(err, QERR_UNSUPPORTED);
|
error_set(errp, QERR_UNSUPPORTED);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,13 +176,13 @@ GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **err)
|
|||||||
* Freeze local file systems using Volume Shadow-copy Service.
|
* Freeze local file systems using Volume Shadow-copy Service.
|
||||||
* The frozen state is limited for up to 10 seconds by VSS.
|
* The frozen state is limited for up to 10 seconds by VSS.
|
||||||
*/
|
*/
|
||||||
int64_t qmp_guest_fsfreeze_freeze(Error **err)
|
int64_t qmp_guest_fsfreeze_freeze(Error **errp)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
|
|
||||||
if (!vss_initialized()) {
|
if (!vss_initialized()) {
|
||||||
error_set(err, QERR_UNSUPPORTED);
|
error_set(errp, QERR_UNSUPPORTED);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,8 +191,8 @@ int64_t qmp_guest_fsfreeze_freeze(Error **err)
|
|||||||
/* cannot risk guest agent blocking itself on a write in this state */
|
/* cannot risk guest agent blocking itself on a write in this state */
|
||||||
ga_set_frozen(ga_state);
|
ga_set_frozen(ga_state);
|
||||||
|
|
||||||
qga_vss_fsfreeze(&i, err, true);
|
qga_vss_fsfreeze(&i, errp, true);
|
||||||
if (error_is_set(err)) {
|
if (error_is_set(errp)) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,16 +210,16 @@ error:
|
|||||||
/*
|
/*
|
||||||
* Thaw local file systems using Volume Shadow-copy Service.
|
* Thaw local file systems using Volume Shadow-copy Service.
|
||||||
*/
|
*/
|
||||||
int64_t qmp_guest_fsfreeze_thaw(Error **err)
|
int64_t qmp_guest_fsfreeze_thaw(Error **errp)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!vss_initialized()) {
|
if (!vss_initialized()) {
|
||||||
error_set(err, QERR_UNSUPPORTED);
|
error_set(errp, QERR_UNSUPPORTED);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
qga_vss_fsfreeze(&i, err, false);
|
qga_vss_fsfreeze(&i, errp, false);
|
||||||
|
|
||||||
ga_unset_frozen(ga_state);
|
ga_unset_frozen(ga_state);
|
||||||
return i;
|
return i;
|
||||||
@ -246,9 +249,9 @@ static void guest_fsfreeze_cleanup(void)
|
|||||||
* Walk list of mounted file systems in the guest, and discard unused
|
* Walk list of mounted file systems in the guest, and discard unused
|
||||||
* areas.
|
* areas.
|
||||||
*/
|
*/
|
||||||
void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **err)
|
void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
|
||||||
{
|
{
|
||||||
error_set(err, QERR_UNSUPPORTED);
|
error_set(errp, QERR_UNSUPPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -256,12 +259,12 @@ typedef enum {
|
|||||||
GUEST_SUSPEND_MODE_RAM
|
GUEST_SUSPEND_MODE_RAM
|
||||||
} GuestSuspendMode;
|
} GuestSuspendMode;
|
||||||
|
|
||||||
static void check_suspend_mode(GuestSuspendMode mode, Error **err)
|
static void check_suspend_mode(GuestSuspendMode mode, Error **errp)
|
||||||
{
|
{
|
||||||
SYSTEM_POWER_CAPABILITIES sys_pwr_caps;
|
SYSTEM_POWER_CAPABILITIES sys_pwr_caps;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
|
|
||||||
if (error_is_set(err)) {
|
if (error_is_set(errp)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ZeroMemory(&sys_pwr_caps, sizeof(sys_pwr_caps));
|
ZeroMemory(&sys_pwr_caps, sizeof(sys_pwr_caps));
|
||||||
@ -291,7 +294,7 @@ static void check_suspend_mode(GuestSuspendMode mode, Error **err)
|
|||||||
|
|
||||||
out:
|
out:
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
error_propagate(err, local_err);
|
error_propagate(errp, local_err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,42 +311,42 @@ static DWORD WINAPI do_suspend(LPVOID opaque)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qmp_guest_suspend_disk(Error **err)
|
void qmp_guest_suspend_disk(Error **errp)
|
||||||
{
|
{
|
||||||
GuestSuspendMode *mode = g_malloc(sizeof(GuestSuspendMode));
|
GuestSuspendMode *mode = g_malloc(sizeof(GuestSuspendMode));
|
||||||
|
|
||||||
*mode = GUEST_SUSPEND_MODE_DISK;
|
*mode = GUEST_SUSPEND_MODE_DISK;
|
||||||
check_suspend_mode(*mode, err);
|
check_suspend_mode(*mode, errp);
|
||||||
acquire_privilege(SE_SHUTDOWN_NAME, err);
|
acquire_privilege(SE_SHUTDOWN_NAME, errp);
|
||||||
execute_async(do_suspend, mode, err);
|
execute_async(do_suspend, mode, errp);
|
||||||
|
|
||||||
if (error_is_set(err)) {
|
if (error_is_set(errp)) {
|
||||||
g_free(mode);
|
g_free(mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void qmp_guest_suspend_ram(Error **err)
|
void qmp_guest_suspend_ram(Error **errp)
|
||||||
{
|
{
|
||||||
GuestSuspendMode *mode = g_malloc(sizeof(GuestSuspendMode));
|
GuestSuspendMode *mode = g_malloc(sizeof(GuestSuspendMode));
|
||||||
|
|
||||||
*mode = GUEST_SUSPEND_MODE_RAM;
|
*mode = GUEST_SUSPEND_MODE_RAM;
|
||||||
check_suspend_mode(*mode, err);
|
check_suspend_mode(*mode, errp);
|
||||||
acquire_privilege(SE_SHUTDOWN_NAME, err);
|
acquire_privilege(SE_SHUTDOWN_NAME, errp);
|
||||||
execute_async(do_suspend, mode, err);
|
execute_async(do_suspend, mode, errp);
|
||||||
|
|
||||||
if (error_is_set(err)) {
|
if (error_is_set(errp)) {
|
||||||
g_free(mode);
|
g_free(mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void qmp_guest_suspend_hybrid(Error **err)
|
void qmp_guest_suspend_hybrid(Error **errp)
|
||||||
{
|
{
|
||||||
error_set(err, QERR_UNSUPPORTED);
|
error_set(errp, QERR_UNSUPPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **err)
|
GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp)
|
||||||
{
|
{
|
||||||
error_set(err, QERR_UNSUPPORTED);
|
error_set(errp, QERR_UNSUPPORTED);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ int64_t qmp_guest_sync(int64_t id, Error **errp)
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qmp_guest_ping(Error **err)
|
void qmp_guest_ping(Error **errp)
|
||||||
{
|
{
|
||||||
slog("guest-ping called");
|
slog("guest-ping called");
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ static void qmp_command_info(QmpCommand *cmd, void *opaque)
|
|||||||
info->supported_commands = cmd_info_list;
|
info->supported_commands = cmd_info_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct GuestAgentInfo *qmp_guest_info(Error **err)
|
struct GuestAgentInfo *qmp_guest_info(Error **errp)
|
||||||
{
|
{
|
||||||
GuestAgentInfo *info = g_malloc0(sizeof(GuestAgentInfo));
|
GuestAgentInfo *info = g_malloc0(sizeof(GuestAgentInfo));
|
||||||
|
|
||||||
|
@ -145,19 +145,19 @@ void ga_uninstall_vss_provider(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Call VSS requester and freeze/thaw filesystems and applications */
|
/* Call VSS requester and freeze/thaw filesystems and applications */
|
||||||
void qga_vss_fsfreeze(int *nr_volume, Error **err, bool freeze)
|
void qga_vss_fsfreeze(int *nr_volume, Error **errp, bool freeze)
|
||||||
{
|
{
|
||||||
const char *func_name = freeze ? "requester_freeze" : "requester_thaw";
|
const char *func_name = freeze ? "requester_freeze" : "requester_thaw";
|
||||||
QGAVSSRequesterFunc func;
|
QGAVSSRequesterFunc func;
|
||||||
ErrorSet errset = {
|
ErrorSet errset = {
|
||||||
.error_set = (ErrorSetFunc)error_set_win32,
|
.error_set = (ErrorSetFunc)error_set_win32,
|
||||||
.errp = (void **)err,
|
.errp = (void **)errp,
|
||||||
.err_class = ERROR_CLASS_GENERIC_ERROR
|
.err_class = ERROR_CLASS_GENERIC_ERROR
|
||||||
};
|
};
|
||||||
|
|
||||||
func = (QGAVSSRequesterFunc)GetProcAddress(provider_lib, func_name);
|
func = (QGAVSSRequesterFunc)GetProcAddress(provider_lib, func_name);
|
||||||
if (!func) {
|
if (!func) {
|
||||||
error_setg_win32(err, GetLastError(), "failed to load %s from %s",
|
error_setg_win32(errp, GetLastError(), "failed to load %s from %s",
|
||||||
func_name, QGA_VSS_DLL);
|
func_name, QGA_VSS_DLL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,6 @@ bool vss_initialized(void);
|
|||||||
int ga_install_vss_provider(void);
|
int ga_install_vss_provider(void);
|
||||||
void ga_uninstall_vss_provider(void);
|
void ga_uninstall_vss_provider(void);
|
||||||
|
|
||||||
void qga_vss_fsfreeze(int *nr_volume, Error **err, bool freeze);
|
void qga_vss_fsfreeze(int *nr_volume, Error **errp, bool freeze);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user