mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge remote-tracking branch 'remotes/qmp-unstable/queue/qmp' into staging
* remotes/qmp-unstable/queue/qmp: (38 commits) Revert "qapi: Clean up superfluous null check in qapi_dealloc_type_str()" qapi: Document optional arguments' backwards compatibility qmp: use valid JSON in transaction example qmp: Don't use error_is_set() to suppress additional errors dump: Drop pointless error_is_set(), DumpState member errp qemu-option: Clean up fragile use of error_is_set() qga: Drop superfluous error_is_set() qga: Clean up fragile use of error_is_set() qapi: Clean up fragile use of error_is_set() tests/qapi-schema: Drop superfluous error_is_set() qapi: Drop redundant, unclean error_is_set() hmp: Guard against misuse of hmp_handle_error() qga: Use return values instead of error_is_set(errp) error: Consistently name Error ** objects errp, and not err qmp: Consistently name Error ** objects errp, and not err qga: Consistently name Error ** objects errp, and not err qmp hmp: Consistently name Error * objects err, and not errp pci-assign: assigned_initfn(): set monitor error in common error handler pci-assign: propagate errors from assign_intx() pci-assign: propagate errors from assign_device() ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
@@ -238,23 +238,35 @@ qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py
|
||||
|
||||
qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\
|
||||
$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
|
||||
$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, " GEN $@")
|
||||
$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \
|
||||
$(gen-out-type) -o qga/qapi-generated -p "qga-" -i $<, \
|
||||
" GEN $@")
|
||||
qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h :\
|
||||
$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
|
||||
$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, " GEN $@")
|
||||
$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \
|
||||
$(gen-out-type) -o qga/qapi-generated -p "qga-" -i $<, \
|
||||
" GEN $@")
|
||||
qga/qapi-generated/qga-qmp-commands.h qga/qapi-generated/qga-qmp-marshal.c :\
|
||||
$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
|
||||
$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, " GEN $@")
|
||||
$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \
|
||||
$(gen-out-type) -o qga/qapi-generated -p "qga-" -i $<, \
|
||||
" GEN $@")
|
||||
|
||||
qapi-types.c qapi-types.h :\
|
||||
$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
|
||||
$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py $(gen-out-type) -o "." -b < $<, " GEN $@")
|
||||
$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \
|
||||
$(gen-out-type) -o "." -b -i $<, \
|
||||
" GEN $@")
|
||||
qapi-visit.c qapi-visit.h :\
|
||||
$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
|
||||
$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py $(gen-out-type) -o "." -b < $<, " GEN $@")
|
||||
$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \
|
||||
$(gen-out-type) -o "." -b -i $<, \
|
||||
" GEN $@")
|
||||
qmp-commands.h qmp-marshal.c :\
|
||||
$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
|
||||
$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -m -o "." < $<, " GEN $@")
|
||||
$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \
|
||||
$(gen-out-type) -o "." -m -i $<, \
|
||||
" GEN $@")
|
||||
|
||||
QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h)
|
||||
$(qga-obj-y) qemu-ga.o: $(QGALIB_GEN)
|
||||
|
||||
+40
-5
@@ -40,6 +40,17 @@ enumeration types and union types.
|
||||
Generally speaking, types definitions should always use CamelCase for the type
|
||||
names. Command names should be all lower case with words separated by a hyphen.
|
||||
|
||||
|
||||
=== Includes ===
|
||||
|
||||
The QAPI schema definitions can be modularized using the 'include' directive:
|
||||
|
||||
{ 'include': 'path/to/file.json'}
|
||||
|
||||
The directive is evaluated recursively, and include paths are relative to the
|
||||
file using the directive.
|
||||
|
||||
|
||||
=== Complex types ===
|
||||
|
||||
A complex type is a dictionary containing a single key whose value is a
|
||||
@@ -49,10 +60,34 @@ example of a complex type is:
|
||||
{ 'type': 'MyType',
|
||||
'data': { 'member1': 'str', 'member2': 'int', '*member3': 'str' } }
|
||||
|
||||
The use of '*' as a prefix to the name means the member is optional. Optional
|
||||
members should always be added to the end of the dictionary to preserve
|
||||
backwards compatibility.
|
||||
The use of '*' as a prefix to the name means the member is optional.
|
||||
|
||||
The default initialization value of an optional argument should not be changed
|
||||
between versions of QEMU unless the new default maintains backward
|
||||
compatibility to the user-visible behavior of the old default.
|
||||
|
||||
With proper documentation, this policy still allows some flexibility; for
|
||||
example, documenting that a default of 0 picks an optimal buffer size allows
|
||||
one release to declare the optimal size at 512 while another release declares
|
||||
the optimal size at 4096 - the user-visible behavior is not the bytes used by
|
||||
the buffer, but the fact that the buffer was optimal size.
|
||||
|
||||
On input structures (only mentioned in the 'data' side of a command), changing
|
||||
from mandatory to optional is safe (older clients will supply the option, and
|
||||
newer clients can benefit from the default); changing from optional to
|
||||
mandatory is backwards incompatible (older clients may be omitting the option,
|
||||
and must continue to work).
|
||||
|
||||
On output structures (only mentioned in the 'returns' side of a command),
|
||||
changing from mandatory to optional is in general unsafe (older clients may be
|
||||
expecting the field, and could crash if it is missing), although it can be done
|
||||
if the only way that the optional argument will be omitted is when it is
|
||||
triggered by the presence of a new input flag to the command that older clients
|
||||
don't know to send. Changing from optional to mandatory is safe.
|
||||
|
||||
A structure that is used in both input and output of various commands
|
||||
must consider the backwards compatibility constraints of both directions
|
||||
of use.
|
||||
|
||||
A complex type definition can specify another complex type as its base.
|
||||
In this case, the fields of the base type are included as top-level fields
|
||||
@@ -221,7 +256,7 @@ created code.
|
||||
Example:
|
||||
|
||||
mdroth@illuin:~/w/qemu2.git$ python scripts/qapi-types.py \
|
||||
--output-dir="qapi-generated" --prefix="example-" < example-schema.json
|
||||
--output-dir="qapi-generated" --prefix="example-" --input-file=example-schema.json
|
||||
mdroth@illuin:~/w/qemu2.git$ cat qapi-generated/example-qapi-types.c
|
||||
/* AUTOMATICALLY GENERATED, DO NOT MODIFY */
|
||||
|
||||
@@ -291,7 +326,7 @@ $(prefix)qapi-visit.h: declarations for previously mentioned visitor
|
||||
Example:
|
||||
|
||||
mdroth@illuin:~/w/qemu2.git$ python scripts/qapi-visit.py \
|
||||
--output-dir="qapi-generated" --prefix="example-" < example-schema.json
|
||||
--output-dir="qapi-generated" --prefix="example-" --input-file=example-schema.json
|
||||
mdroth@illuin:~/w/qemu2.git$ cat qapi-generated/example-qapi-visit.c
|
||||
/* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT MODIFY */
|
||||
|
||||
|
||||
@@ -308,12 +308,12 @@ Here's the implementation of the "hello-world" HMP command:
|
||||
void hmp_hello_world(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
const char *message = qdict_get_try_str(qdict, "message");
|
||||
Error *errp = NULL;
|
||||
Error *err = NULL;
|
||||
|
||||
qmp_hello_world(!!message, message, &errp);
|
||||
if (errp) {
|
||||
monitor_printf(mon, "%s\n", error_get_pretty(errp));
|
||||
error_free(errp);
|
||||
qmp_hello_world(!!message, message, &err);
|
||||
if (err) {
|
||||
monitor_printf(mon, "%s\n", error_get_pretty(err));
|
||||
error_free(err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -328,7 +328,7 @@ There are three important points to be noticed:
|
||||
2. hmp_hello_world() performs error checking. In this example we just print
|
||||
the error description to the user, but we could do more, like taking
|
||||
different actions depending on the error qmp_hello_world() returns
|
||||
3. The "errp" variable must be initialized to NULL before performing the
|
||||
3. The "err" variable must be initialized to NULL before performing the
|
||||
QMP call
|
||||
|
||||
There's one last step to actually make the command available to monitor users,
|
||||
@@ -480,12 +480,12 @@ Here's the HMP counterpart of the query-alarm-clock command:
|
||||
void hmp_info_alarm_clock(Monitor *mon)
|
||||
{
|
||||
QemuAlarmClock *clock;
|
||||
Error *errp = NULL;
|
||||
Error *err = NULL;
|
||||
|
||||
clock = qmp_query_alarm_clock(&errp);
|
||||
if (errp) {
|
||||
clock = qmp_query_alarm_clock(&err);
|
||||
if (err) {
|
||||
monitor_printf(mon, "Could not query alarm clock information\n");
|
||||
error_free(errp);
|
||||
error_free(err);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -631,12 +631,12 @@ has to traverse the list, it's shown below for reference:
|
||||
void hmp_info_alarm_methods(Monitor *mon)
|
||||
{
|
||||
TimerAlarmMethodList *method_list, *method;
|
||||
Error *errp = NULL;
|
||||
Error *err = NULL;
|
||||
|
||||
method_list = qmp_query_alarm_methods(&errp);
|
||||
if (errp) {
|
||||
method_list = qmp_query_alarm_methods(&err);
|
||||
if (err) {
|
||||
monitor_printf(mon, "Could not query alarm methods\n");
|
||||
error_free(errp);
|
||||
error_free(err);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,6 @@ typedef struct DumpState {
|
||||
bool has_filter;
|
||||
int64_t begin;
|
||||
int64_t length;
|
||||
Error **errp;
|
||||
|
||||
uint8_t *note_buf; /* buffer for notes */
|
||||
size_t note_buf_offset; /* the writing place in note_buf */
|
||||
@@ -1570,7 +1569,6 @@ static int dump_init(DumpState *s, int fd, bool has_format,
|
||||
nr_cpus++;
|
||||
}
|
||||
|
||||
s->errp = errp;
|
||||
s->fd = fd;
|
||||
s->has_filter = has_filter;
|
||||
s->begin = begin;
|
||||
@@ -1780,11 +1778,11 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin,
|
||||
}
|
||||
|
||||
if (has_format && format != DUMP_GUEST_MEMORY_FORMAT_ELF) {
|
||||
if (create_kdump_vmcore(s) < 0 && !error_is_set(s->errp)) {
|
||||
if (create_kdump_vmcore(s) < 0) {
|
||||
error_set(errp, QERR_IO_ERROR);
|
||||
}
|
||||
} else {
|
||||
if (create_vmcore(s) < 0 && !error_is_set(s->errp)) {
|
||||
if (create_vmcore(s) < 0) {
|
||||
error_set(errp, QERR_IO_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,8 @@
|
||||
|
||||
static void hmp_handle_error(Monitor *mon, Error **errp)
|
||||
{
|
||||
if (error_is_set(errp)) {
|
||||
assert(errp);
|
||||
if (*errp) {
|
||||
monitor_printf(mon, "%s\n", error_get_pretty(*errp));
|
||||
error_free(*errp);
|
||||
}
|
||||
@@ -754,10 +755,10 @@ void hmp_memsave(Monitor *mon, const QDict *qdict)
|
||||
uint32_t size = qdict_get_int(qdict, "size");
|
||||
const char *filename = qdict_get_str(qdict, "filename");
|
||||
uint64_t addr = qdict_get_int(qdict, "val");
|
||||
Error *errp = NULL;
|
||||
Error *err = NULL;
|
||||
|
||||
qmp_memsave(addr, size, filename, true, monitor_get_cpu_index(), &errp);
|
||||
hmp_handle_error(mon, &errp);
|
||||
qmp_memsave(addr, size, filename, true, monitor_get_cpu_index(), &err);
|
||||
hmp_handle_error(mon, &err);
|
||||
}
|
||||
|
||||
void hmp_pmemsave(Monitor *mon, const QDict *qdict)
|
||||
@@ -765,21 +766,21 @@ void hmp_pmemsave(Monitor *mon, const QDict *qdict)
|
||||
uint32_t size = qdict_get_int(qdict, "size");
|
||||
const char *filename = qdict_get_str(qdict, "filename");
|
||||
uint64_t addr = qdict_get_int(qdict, "val");
|
||||
Error *errp = NULL;
|
||||
Error *err = NULL;
|
||||
|
||||
qmp_pmemsave(addr, size, filename, &errp);
|
||||
hmp_handle_error(mon, &errp);
|
||||
qmp_pmemsave(addr, size, filename, &err);
|
||||
hmp_handle_error(mon, &err);
|
||||
}
|
||||
|
||||
void hmp_ringbuf_write(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
const char *chardev = qdict_get_str(qdict, "device");
|
||||
const char *data = qdict_get_str(qdict, "data");
|
||||
Error *errp = NULL;
|
||||
Error *err = NULL;
|
||||
|
||||
qmp_ringbuf_write(chardev, data, false, 0, &errp);
|
||||
qmp_ringbuf_write(chardev, data, false, 0, &err);
|
||||
|
||||
hmp_handle_error(mon, &errp);
|
||||
hmp_handle_error(mon, &err);
|
||||
}
|
||||
|
||||
void hmp_ringbuf_read(Monitor *mon, const QDict *qdict)
|
||||
@@ -787,13 +788,13 @@ void hmp_ringbuf_read(Monitor *mon, const QDict *qdict)
|
||||
uint32_t size = qdict_get_int(qdict, "size");
|
||||
const char *chardev = qdict_get_str(qdict, "device");
|
||||
char *data;
|
||||
Error *errp = NULL;
|
||||
Error *err = NULL;
|
||||
int i;
|
||||
|
||||
data = qmp_ringbuf_read(chardev, size, false, 0, &errp);
|
||||
if (errp) {
|
||||
monitor_printf(mon, "%s\n", error_get_pretty(errp));
|
||||
error_free(errp);
|
||||
data = qmp_ringbuf_read(chardev, size, false, 0, &err);
|
||||
if (err) {
|
||||
monitor_printf(mon, "%s\n", error_get_pretty(err));
|
||||
error_free(err);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -828,7 +829,7 @@ static bool key_is_missing(const BlockInfo *bdev)
|
||||
void hmp_cont(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
BlockInfoList *bdev_list, *bdev;
|
||||
Error *errp = NULL;
|
||||
Error *err = NULL;
|
||||
|
||||
bdev_list = qmp_query_block(NULL);
|
||||
for (bdev = bdev_list; bdev; bdev = bdev->next) {
|
||||
@@ -839,8 +840,8 @@ void hmp_cont(Monitor *mon, const QDict *qdict)
|
||||
}
|
||||
}
|
||||
|
||||
qmp_cont(&errp);
|
||||
hmp_handle_error(mon, &errp);
|
||||
qmp_cont(&err);
|
||||
hmp_handle_error(mon, &err);
|
||||
|
||||
out:
|
||||
qapi_free_BlockInfoList(bdev_list);
|
||||
@@ -853,41 +854,41 @@ void hmp_system_wakeup(Monitor *mon, const QDict *qdict)
|
||||
|
||||
void hmp_inject_nmi(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
Error *errp = NULL;
|
||||
Error *err = NULL;
|
||||
|
||||
qmp_inject_nmi(&errp);
|
||||
hmp_handle_error(mon, &errp);
|
||||
qmp_inject_nmi(&err);
|
||||
hmp_handle_error(mon, &err);
|
||||
}
|
||||
|
||||
void hmp_set_link(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
const char *name = qdict_get_str(qdict, "name");
|
||||
int up = qdict_get_bool(qdict, "up");
|
||||
Error *errp = NULL;
|
||||
Error *err = NULL;
|
||||
|
||||
qmp_set_link(name, up, &errp);
|
||||
hmp_handle_error(mon, &errp);
|
||||
qmp_set_link(name, up, &err);
|
||||
hmp_handle_error(mon, &err);
|
||||
}
|
||||
|
||||
void hmp_block_passwd(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
const char *device = qdict_get_str(qdict, "device");
|
||||
const char *password = qdict_get_str(qdict, "password");
|
||||
Error *errp = NULL;
|
||||
Error *err = NULL;
|
||||
|
||||
qmp_block_passwd(true, device, false, NULL, password, &errp);
|
||||
hmp_handle_error(mon, &errp);
|
||||
qmp_block_passwd(true, device, false, NULL, password, &err);
|
||||
hmp_handle_error(mon, &err);
|
||||
}
|
||||
|
||||
void hmp_balloon(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
int64_t value = qdict_get_int(qdict, "value");
|
||||
Error *errp = NULL;
|
||||
Error *err = NULL;
|
||||
|
||||
qmp_balloon(value, &errp);
|
||||
if (errp) {
|
||||
monitor_printf(mon, "balloon: %s\n", error_get_pretty(errp));
|
||||
error_free(errp);
|
||||
qmp_balloon(value, &err);
|
||||
if (err) {
|
||||
monitor_printf(mon, "balloon: %s\n", error_get_pretty(err));
|
||||
error_free(err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -895,10 +896,10 @@ void hmp_block_resize(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
const char *device = qdict_get_str(qdict, "device");
|
||||
int64_t size = qdict_get_int(qdict, "size");
|
||||
Error *errp = NULL;
|
||||
Error *err = NULL;
|
||||
|
||||
qmp_block_resize(true, device, false, NULL, size, &errp);
|
||||
hmp_handle_error(mon, &errp);
|
||||
qmp_block_resize(true, device, false, NULL, size, &err);
|
||||
hmp_handle_error(mon, &err);
|
||||
}
|
||||
|
||||
void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
|
||||
@@ -909,11 +910,11 @@ void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
|
||||
int reuse = qdict_get_try_bool(qdict, "reuse", 0);
|
||||
int full = qdict_get_try_bool(qdict, "full", 0);
|
||||
enum NewImageMode mode;
|
||||
Error *errp = NULL;
|
||||
Error *err = NULL;
|
||||
|
||||
if (!filename) {
|
||||
error_set(&errp, QERR_MISSING_PARAMETER, "target");
|
||||
hmp_handle_error(mon, &errp);
|
||||
error_set(&err, QERR_MISSING_PARAMETER, "target");
|
||||
hmp_handle_error(mon, &err);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -926,8 +927,8 @@ void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
|
||||
qmp_drive_mirror(device, filename, !!format, format,
|
||||
full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP,
|
||||
true, mode, false, 0, false, 0, false, 0,
|
||||
false, 0, false, 0, &errp);
|
||||
hmp_handle_error(mon, &errp);
|
||||
false, 0, false, 0, &err);
|
||||
hmp_handle_error(mon, &err);
|
||||
}
|
||||
|
||||
void hmp_drive_backup(Monitor *mon, const QDict *qdict)
|
||||
@@ -938,11 +939,11 @@ void hmp_drive_backup(Monitor *mon, const QDict *qdict)
|
||||
int reuse = qdict_get_try_bool(qdict, "reuse", 0);
|
||||
int full = qdict_get_try_bool(qdict, "full", 0);
|
||||
enum NewImageMode mode;
|
||||
Error *errp = NULL;
|
||||
Error *err = NULL;
|
||||
|
||||
if (!filename) {
|
||||
error_set(&errp, QERR_MISSING_PARAMETER, "target");
|
||||
hmp_handle_error(mon, &errp);
|
||||
error_set(&err, QERR_MISSING_PARAMETER, "target");
|
||||
hmp_handle_error(mon, &err);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -954,8 +955,8 @@ void hmp_drive_backup(Monitor *mon, const QDict *qdict)
|
||||
|
||||
qmp_drive_backup(device, filename, !!format, format,
|
||||
full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP,
|
||||
true, mode, false, 0, false, 0, false, 0, &errp);
|
||||
hmp_handle_error(mon, &errp);
|
||||
true, mode, false, 0, false, 0, false, 0, &err);
|
||||
hmp_handle_error(mon, &err);
|
||||
}
|
||||
|
||||
void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
|
||||
@@ -965,13 +966,13 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
|
||||
const char *format = qdict_get_try_str(qdict, "format");
|
||||
int reuse = qdict_get_try_bool(qdict, "reuse", 0);
|
||||
enum NewImageMode mode;
|
||||
Error *errp = NULL;
|
||||
Error *err = NULL;
|
||||
|
||||
if (!filename) {
|
||||
/* In the future, if 'snapshot-file' is not specified, the snapshot
|
||||
will be taken internally. Today it's actually required. */
|
||||
error_set(&errp, QERR_MISSING_PARAMETER, "snapshot-file");
|
||||
hmp_handle_error(mon, &errp);
|
||||
error_set(&err, QERR_MISSING_PARAMETER, "snapshot-file");
|
||||
hmp_handle_error(mon, &err);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -979,18 +980,18 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
|
||||
qmp_blockdev_snapshot_sync(true, device, false, NULL,
|
||||
filename, false, NULL,
|
||||
!!format, format,
|
||||
true, mode, &errp);
|
||||
hmp_handle_error(mon, &errp);
|
||||
true, mode, &err);
|
||||
hmp_handle_error(mon, &err);
|
||||
}
|
||||
|
||||
void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
const char *device = qdict_get_str(qdict, "device");
|
||||
const char *name = qdict_get_str(qdict, "name");
|
||||
Error *errp = NULL;
|
||||
Error *err = NULL;
|
||||
|
||||
qmp_blockdev_snapshot_internal_sync(device, name, &errp);
|
||||
hmp_handle_error(mon, &errp);
|
||||
qmp_blockdev_snapshot_internal_sync(device, name, &err);
|
||||
hmp_handle_error(mon, &err);
|
||||
}
|
||||
|
||||
void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict)
|
||||
@@ -998,11 +999,11 @@ void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict)
|
||||
const char *device = qdict_get_str(qdict, "device");
|
||||
const char *name = qdict_get_str(qdict, "name");
|
||||
const char *id = qdict_get_try_str(qdict, "id");
|
||||
Error *errp = NULL;
|
||||
Error *err = NULL;
|
||||
|
||||
qmp_blockdev_snapshot_delete_internal_sync(device, !!id, id,
|
||||
true, name, &errp);
|
||||
hmp_handle_error(mon, &errp);
|
||||
true, name, &err);
|
||||
hmp_handle_error(mon, &err);
|
||||
}
|
||||
|
||||
void hmp_migrate_cancel(Monitor *mon, const QDict *qdict)
|
||||
@@ -1310,7 +1311,7 @@ void hmp_device_del(Monitor *mon, const QDict *qdict)
|
||||
|
||||
void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
Error *errp = NULL;
|
||||
Error *err = NULL;
|
||||
int paging = qdict_get_try_bool(qdict, "paging", 0);
|
||||
int zlib = qdict_get_try_bool(qdict, "zlib", 0);
|
||||
int lzo = qdict_get_try_bool(qdict, "lzo", 0);
|
||||
@@ -1324,8 +1325,8 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
|
||||
char *prot;
|
||||
|
||||
if (zlib + lzo + snappy > 1) {
|
||||
error_setg(&errp, "only one of '-z|-l|-s' can be set");
|
||||
hmp_handle_error(mon, &errp);
|
||||
error_setg(&err, "only one of '-z|-l|-s' can be set");
|
||||
hmp_handle_error(mon, &err);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1351,8 +1352,8 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
|
||||
prot = g_strconcat("file:", file, NULL);
|
||||
|
||||
qmp_dump_guest_memory(paging, prot, has_begin, begin, has_length, length,
|
||||
true, dump_format, &errp);
|
||||
hmp_handle_error(mon, &errp);
|
||||
true, dump_format, &err);
|
||||
hmp_handle_error(mon, &err);
|
||||
g_free(prot);
|
||||
}
|
||||
|
||||
@@ -1444,19 +1445,19 @@ out:
|
||||
void hmp_getfd(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
const char *fdname = qdict_get_str(qdict, "fdname");
|
||||
Error *errp = NULL;
|
||||
Error *err = NULL;
|
||||
|
||||
qmp_getfd(fdname, &errp);
|
||||
hmp_handle_error(mon, &errp);
|
||||
qmp_getfd(fdname, &err);
|
||||
hmp_handle_error(mon, &err);
|
||||
}
|
||||
|
||||
void hmp_closefd(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
const char *fdname = qdict_get_str(qdict, "fdname");
|
||||
Error *errp = NULL;
|
||||
Error *err = NULL;
|
||||
|
||||
qmp_closefd(fdname, &errp);
|
||||
hmp_handle_error(mon, &errp);
|
||||
qmp_closefd(fdname, &err);
|
||||
hmp_handle_error(mon, &err);
|
||||
}
|
||||
|
||||
void hmp_send_key(Monitor *mon, const QDict *qdict)
|
||||
@@ -1606,10 +1607,10 @@ void hmp_nbd_server_add(Monitor *mon, const QDict *qdict)
|
||||
|
||||
void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
Error *errp = NULL;
|
||||
Error *err = NULL;
|
||||
|
||||
qmp_nbd_server_stop(&errp);
|
||||
hmp_handle_error(mon, &errp);
|
||||
qmp_nbd_server_stop(&err);
|
||||
hmp_handle_error(mon, &err);
|
||||
}
|
||||
|
||||
void hmp_cpu_add(Monitor *mon, const QDict *qdict)
|
||||
|
||||
+168
-105
File diff suppressed because it is too large
Load Diff
+26
-6
@@ -2012,6 +2012,25 @@ static void pci_del_option_rom(PCIDevice *pdev)
|
||||
* in pci config space */
|
||||
int pci_add_capability(PCIDevice *pdev, uint8_t cap_id,
|
||||
uint8_t offset, uint8_t size)
|
||||
{
|
||||
int ret;
|
||||
Error *local_err = NULL;
|
||||
|
||||
ret = pci_add_capability2(pdev, cap_id, offset, size, &local_err);
|
||||
if (local_err) {
|
||||
assert(ret < 0);
|
||||
error_report("%s", error_get_pretty(local_err));
|
||||
error_free(local_err);
|
||||
} else {
|
||||
/* success implies a positive offset in config space */
|
||||
assert(ret > 0);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int pci_add_capability2(PCIDevice *pdev, uint8_t cap_id,
|
||||
uint8_t offset, uint8_t size,
|
||||
Error **errp)
|
||||
{
|
||||
uint8_t *config;
|
||||
int i, overlapping_cap;
|
||||
@@ -2019,6 +2038,7 @@ int pci_add_capability(PCIDevice *pdev, uint8_t cap_id,
|
||||
if (!offset) {
|
||||
offset = pci_find_space(pdev, size);
|
||||
if (!offset) {
|
||||
error_setg(errp, "out of PCI config space");
|
||||
return -ENOSPC;
|
||||
}
|
||||
} else {
|
||||
@@ -2029,12 +2049,12 @@ int pci_add_capability(PCIDevice *pdev, uint8_t cap_id,
|
||||
for (i = offset; i < offset + size; i++) {
|
||||
overlapping_cap = pci_find_capability_at_offset(pdev, i);
|
||||
if (overlapping_cap) {
|
||||
fprintf(stderr, "ERROR: %s:%02x:%02x.%x "
|
||||
"Attempt to add PCI capability %x at offset "
|
||||
"%x overlaps existing capability %x at offset %x\n",
|
||||
pci_root_bus_path(pdev), pci_bus_num(pdev->bus),
|
||||
PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn),
|
||||
cap_id, offset, overlapping_cap, i);
|
||||
error_setg(errp, "%s:%02x:%02x.%x "
|
||||
"Attempt to add PCI capability %x at offset "
|
||||
"%x overlaps existing capability %x at offset %x",
|
||||
pci_root_bus_path(pdev), pci_bus_num(pdev->bus),
|
||||
PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn),
|
||||
cap_id, offset, overlapping_cap, i);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "hw/qdev.h"
|
||||
#include "exec/memory.h"
|
||||
#include "sysemu/dma.h"
|
||||
#include "qapi/error.h"
|
||||
|
||||
/* PCI includes legacy ISA access. */
|
||||
#include "hw/isa/isa.h"
|
||||
@@ -308,6 +309,9 @@ pcibus_t pci_get_bar_addr(PCIDevice *pci_dev, int region_num);
|
||||
|
||||
int pci_add_capability(PCIDevice *pdev, uint8_t cap_id,
|
||||
uint8_t offset, uint8_t size);
|
||||
int pci_add_capability2(PCIDevice *pdev, uint8_t cap_id,
|
||||
uint8_t offset, uint8_t size,
|
||||
Error **errp);
|
||||
|
||||
void pci_del_capability(PCIDevice *pci_dev, uint8_t cap_id, uint8_t cap_size);
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ int monitor_read_block_device_key(Monitor *mon, const char *device,
|
||||
|
||||
int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp);
|
||||
int monitor_handle_fd_param(Monitor *mon, const char *fdname);
|
||||
int monitor_handle_fd_param2(Monitor *mon, const char *fdname, Error **errp);
|
||||
|
||||
void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
|
||||
GCC_FMT_ATTR(2, 0);
|
||||
|
||||
+16
-11
@@ -27,14 +27,16 @@ typedef struct Error Error;
|
||||
* printf-style human message. This function is not meant to be used outside
|
||||
* of QEMU.
|
||||
*/
|
||||
void error_set(Error **err, ErrorClass err_class, const char *fmt, ...) GCC_FMT_ATTR(3, 4);
|
||||
void error_set(Error **errp, ErrorClass err_class, const char *fmt, ...)
|
||||
GCC_FMT_ATTR(3, 4);
|
||||
|
||||
/**
|
||||
* Set an indirect pointer to an error given a ErrorClass value and a
|
||||
* printf-style human message, followed by a strerror() string if
|
||||
* @os_error is not zero.
|
||||
*/
|
||||
void error_set_errno(Error **err, int os_error, ErrorClass err_class, const char *fmt, ...) GCC_FMT_ATTR(4, 5);
|
||||
void error_set_errno(Error **errp, int os_error, ErrorClass err_class,
|
||||
const char *fmt, ...) GCC_FMT_ATTR(4, 5);
|
||||
|
||||
#ifdef _WIN32
|
||||
/**
|
||||
@@ -42,19 +44,22 @@ void error_set_errno(Error **err, int os_error, ErrorClass err_class, const char
|
||||
* printf-style human message, followed by a g_win32_error_message() string if
|
||||
* @win32_err is not zero.
|
||||
*/
|
||||
void error_set_win32(Error **err, int win32_err, ErrorClass err_class, const char *fmt, ...) GCC_FMT_ATTR(4, 5);
|
||||
void error_set_win32(Error **errp, int win32_err, ErrorClass err_class,
|
||||
const char *fmt, ...) GCC_FMT_ATTR(4, 5);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Same as error_set(), but sets a generic error
|
||||
*/
|
||||
#define error_setg(err, fmt, ...) \
|
||||
error_set(err, ERROR_CLASS_GENERIC_ERROR, fmt, ## __VA_ARGS__)
|
||||
#define error_setg_errno(err, os_error, fmt, ...) \
|
||||
error_set_errno(err, os_error, ERROR_CLASS_GENERIC_ERROR, fmt, ## __VA_ARGS__)
|
||||
#define error_setg(errp, fmt, ...) \
|
||||
error_set(errp, ERROR_CLASS_GENERIC_ERROR, fmt, ## __VA_ARGS__)
|
||||
#define error_setg_errno(errp, os_error, fmt, ...) \
|
||||
error_set_errno(errp, os_error, ERROR_CLASS_GENERIC_ERROR, \
|
||||
fmt, ## __VA_ARGS__)
|
||||
#ifdef _WIN32
|
||||
#define error_setg_win32(err, win32_err, fmt, ...) \
|
||||
error_set_win32(err, win32_err, ERROR_CLASS_GENERIC_ERROR, fmt, ## __VA_ARGS__)
|
||||
#define error_setg_win32(errp, win32_err, fmt, ...) \
|
||||
error_set_win32(errp, win32_err, ERROR_CLASS_GENERIC_ERROR, \
|
||||
fmt, ## __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -66,7 +71,7 @@ void error_setg_file_open(Error **errp, int os_errno, const char *filename);
|
||||
* Returns true if an indirect pointer to an error is pointing to a valid
|
||||
* error object.
|
||||
*/
|
||||
bool error_is_set(Error **err);
|
||||
bool error_is_set(Error **errp);
|
||||
|
||||
/*
|
||||
* Get the error class of an error object.
|
||||
@@ -88,7 +93,7 @@ const char *error_get_pretty(Error *err);
|
||||
* always transfer ownership of the error reference and handles the case where
|
||||
* dst_err is NULL correctly. Errors after the first are discarded.
|
||||
*/
|
||||
void error_propagate(Error **dst_err, Error *local_err);
|
||||
void error_propagate(Error **dst_errp, Error *local_err);
|
||||
|
||||
/**
|
||||
* Free an error object.
|
||||
|
||||
@@ -50,7 +50,7 @@ void qmp_enable_command(const char *name);
|
||||
bool qmp_command_is_enabled(const QmpCommand *cmd);
|
||||
const char *qmp_command_name(const QmpCommand *cmd);
|
||||
bool qmp_has_success_response(const QmpCommand *cmd);
|
||||
QObject *qmp_build_error_object(Error *errp);
|
||||
QObject *qmp_build_error_object(Error *err);
|
||||
typedef void (*qmp_cmd_callback_fn)(QmpCommand *cmd, void *opaque);
|
||||
void qmp_for_each_command(qmp_cmd_callback_fn fn, void *opaque);
|
||||
|
||||
|
||||
@@ -2611,16 +2611,33 @@ int monitor_handle_fd_param(Monitor *mon, const char *fdname)
|
||||
int fd;
|
||||
Error *local_err = NULL;
|
||||
|
||||
if (!qemu_isdigit(fdname[0]) && mon) {
|
||||
fd = monitor_handle_fd_param2(mon, fdname, &local_err);
|
||||
if (local_err) {
|
||||
qerror_report_err(local_err);
|
||||
error_free(local_err);
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
int monitor_handle_fd_param2(Monitor *mon, const char *fdname, Error **errp)
|
||||
{
|
||||
int fd;
|
||||
Error *local_err = NULL;
|
||||
|
||||
if (!qemu_isdigit(fdname[0]) && mon) {
|
||||
fd = monitor_get_fd(mon, fdname, &local_err);
|
||||
if (fd == -1) {
|
||||
qerror_report_err(local_err);
|
||||
error_free(local_err);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
fd = qemu_parse_fd(fdname);
|
||||
if (fd == -1) {
|
||||
error_setg(&local_err, "Invalid file descriptor number '%s'",
|
||||
fdname);
|
||||
}
|
||||
}
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
assert(fd == -1);
|
||||
} else {
|
||||
assert(fd != -1);
|
||||
}
|
||||
|
||||
return fd;
|
||||
|
||||
+6
-5
@@ -472,13 +472,14 @@ opts_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp)
|
||||
|
||||
val = strtosz_suffix(opt->str ? opt->str : "", &endptr,
|
||||
STRTOSZ_DEFSUFFIX_B);
|
||||
if (val != -1 && *endptr == '\0') {
|
||||
*obj = val;
|
||||
processed(ov, name);
|
||||
if (val < 0 || *endptr) {
|
||||
error_set(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
|
||||
"a size value representible as a non-negative int64");
|
||||
return;
|
||||
}
|
||||
error_set(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
|
||||
"a size value representible as a non-negative int64");
|
||||
|
||||
*obj = val;
|
||||
processed(ov, name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -131,7 +131,9 @@ static void qapi_dealloc_end_list(Visitor *v, Error **errp)
|
||||
static void qapi_dealloc_type_str(Visitor *v, char **obj, const char *name,
|
||||
Error **errp)
|
||||
{
|
||||
g_free(*obj);
|
||||
if (obj) {
|
||||
g_free(*obj);
|
||||
}
|
||||
}
|
||||
|
||||
static void qapi_dealloc_type_int(Visitor *v, int64_t *obj, const char *name,
|
||||
|
||||
+12
-12
@@ -62,14 +62,14 @@ static QDict *qmp_dispatch_check_obj(const QObject *request, Error **errp)
|
||||
|
||||
static QObject *do_qmp_dispatch(QObject *request, Error **errp)
|
||||
{
|
||||
Error *local_err = NULL;
|
||||
const char *command;
|
||||
QDict *args, *dict;
|
||||
QmpCommand *cmd;
|
||||
QObject *ret = NULL;
|
||||
|
||||
|
||||
dict = qmp_dispatch_check_obj(request, errp);
|
||||
if (!dict || error_is_set(errp)) {
|
||||
if (!dict) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -94,13 +94,13 @@ static QObject *do_qmp_dispatch(QObject *request, Error **errp)
|
||||
|
||||
switch (cmd->type) {
|
||||
case QCT_NORMAL:
|
||||
cmd->fn(args, &ret, errp);
|
||||
if (!error_is_set(errp)) {
|
||||
if (cmd->options & QCO_NO_SUCCESS_RESP) {
|
||||
g_assert(!ret);
|
||||
} else if (!ret) {
|
||||
ret = QOBJECT(qdict_new());
|
||||
}
|
||||
cmd->fn(args, &ret, &local_err);
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
} else if (cmd->options & QCO_NO_SUCCESS_RESP) {
|
||||
g_assert(!ret);
|
||||
} else if (!ret) {
|
||||
ret = QOBJECT(qdict_new());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -110,11 +110,11 @@ static QObject *do_qmp_dispatch(QObject *request, Error **errp)
|
||||
return ret;
|
||||
}
|
||||
|
||||
QObject *qmp_build_error_object(Error *errp)
|
||||
QObject *qmp_build_error_object(Error *err)
|
||||
{
|
||||
return qobject_from_jsonf("{ 'class': %s, 'desc': %s }",
|
||||
ErrorClass_lookup[error_get_class(errp)],
|
||||
error_get_pretty(errp));
|
||||
ErrorClass_lookup[error_get_class(err)],
|
||||
error_get_pretty(err));
|
||||
}
|
||||
|
||||
QObject *qmp_dispatch(QObject *request)
|
||||
|
||||
+113
-100
File diff suppressed because it is too large
Load Diff
+63
-60
@@ -29,16 +29,12 @@
|
||||
(365 * (1970 - 1601) + \
|
||||
(1970 - 1601) / 4 - 3))
|
||||
|
||||
static void acquire_privilege(const char *name, Error **err)
|
||||
static void acquire_privilege(const char *name, Error **errp)
|
||||
{
|
||||
HANDLE token;
|
||||
TOKEN_PRIVILEGES priv;
|
||||
Error *local_err = NULL;
|
||||
|
||||
if (error_is_set(err)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (OpenProcessToken(GetCurrentProcess(),
|
||||
TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &token))
|
||||
{
|
||||
@@ -65,27 +61,26 @@ static void acquire_privilege(const char *name, Error **err)
|
||||
|
||||
out:
|
||||
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;
|
||||
|
||||
if (error_is_set(err)) {
|
||||
return;
|
||||
}
|
||||
HANDLE thread = CreateThread(NULL, 0, func, opaque, 0, NULL);
|
||||
if (!thread) {
|
||||
error_set(&local_err, QERR_QGA_COMMAND_FAILED,
|
||||
"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)
|
||||
{
|
||||
Error *local_err = NULL;
|
||||
UINT shutdown_flag = EWX_FORCE;
|
||||
|
||||
slog("guest-shutdown called, mode: %s", mode);
|
||||
@@ -97,68 +92,71 @@ void qmp_guest_shutdown(bool has_mode, const char *mode, Error **err)
|
||||
} else if (strcmp(mode, "reboot") == 0) {
|
||||
shutdown_flag |= EWX_REBOOT;
|
||||
} else {
|
||||
error_set(err, QERR_INVALID_PARAMETER_VALUE, "mode",
|
||||
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "mode",
|
||||
"halt|powerdown|reboot");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Request a shutdown privilege, but try to shut down the system
|
||||
anyway. */
|
||||
acquire_privilege(SE_SHUTDOWN_NAME, err);
|
||||
if (error_is_set(err)) {
|
||||
acquire_privilege(SE_SHUTDOWN_NAME, &local_err);
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ExitWindowsEx(shutdown_flag, SHTDN_REASON_FLAG_PLANNED)) {
|
||||
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;
|
||||
}
|
||||
|
||||
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,
|
||||
int64_t count, Error **err)
|
||||
int64_t count, Error **errp)
|
||||
{
|
||||
error_set(err, QERR_UNSUPPORTED);
|
||||
error_set(errp, QERR_UNSUPPORTED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
*/
|
||||
GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **err)
|
||||
GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **errp)
|
||||
{
|
||||
if (!vss_initialized()) {
|
||||
error_set(err, QERR_UNSUPPORTED);
|
||||
error_set(errp, QERR_UNSUPPORTED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -173,13 +171,13 @@ GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **err)
|
||||
* Freeze local file systems using Volume Shadow-copy Service.
|
||||
* 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;
|
||||
Error *local_err = NULL;
|
||||
|
||||
if (!vss_initialized()) {
|
||||
error_set(err, QERR_UNSUPPORTED);
|
||||
error_set(errp, QERR_UNSUPPORTED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -188,14 +186,16 @@ int64_t qmp_guest_fsfreeze_freeze(Error **err)
|
||||
/* cannot risk guest agent blocking itself on a write in this state */
|
||||
ga_set_frozen(ga_state);
|
||||
|
||||
qga_vss_fsfreeze(&i, err, true);
|
||||
if (error_is_set(err)) {
|
||||
qga_vss_fsfreeze(&i, &local_err, true);
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
goto error;
|
||||
}
|
||||
|
||||
return i;
|
||||
|
||||
error:
|
||||
local_err = NULL;
|
||||
qmp_guest_fsfreeze_thaw(&local_err);
|
||||
if (local_err) {
|
||||
g_debug("cleanup thaw: %s", error_get_pretty(local_err));
|
||||
@@ -207,16 +207,16 @@ error:
|
||||
/*
|
||||
* 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;
|
||||
|
||||
if (!vss_initialized()) {
|
||||
error_set(err, QERR_UNSUPPORTED);
|
||||
error_set(errp, QERR_UNSUPPORTED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
qga_vss_fsfreeze(&i, err, false);
|
||||
qga_vss_fsfreeze(&i, errp, false);
|
||||
|
||||
ga_unset_frozen(ga_state);
|
||||
return i;
|
||||
@@ -246,9 +246,9 @@ static void guest_fsfreeze_cleanup(void)
|
||||
* Walk list of mounted file systems in the guest, and discard unused
|
||||
* 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 {
|
||||
@@ -256,14 +256,11 @@ typedef enum {
|
||||
GUEST_SUSPEND_MODE_RAM
|
||||
} 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;
|
||||
Error *local_err = NULL;
|
||||
|
||||
if (error_is_set(err)) {
|
||||
return;
|
||||
}
|
||||
ZeroMemory(&sys_pwr_caps, sizeof(sys_pwr_caps));
|
||||
if (!GetPwrCapabilities(&sys_pwr_caps)) {
|
||||
error_set(&local_err, QERR_QGA_COMMAND_FAILED,
|
||||
@@ -291,7 +288,7 @@ static void check_suspend_mode(GuestSuspendMode mode, Error **err)
|
||||
|
||||
out:
|
||||
if (local_err) {
|
||||
error_propagate(err, local_err);
|
||||
error_propagate(errp, local_err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,42 +305,46 @@ static DWORD WINAPI do_suspend(LPVOID opaque)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void qmp_guest_suspend_disk(Error **err)
|
||||
void qmp_guest_suspend_disk(Error **errp)
|
||||
{
|
||||
Error *local_err = NULL;
|
||||
GuestSuspendMode *mode = g_malloc(sizeof(GuestSuspendMode));
|
||||
|
||||
*mode = GUEST_SUSPEND_MODE_DISK;
|
||||
check_suspend_mode(*mode, err);
|
||||
acquire_privilege(SE_SHUTDOWN_NAME, err);
|
||||
execute_async(do_suspend, mode, err);
|
||||
check_suspend_mode(*mode, &local_err);
|
||||
acquire_privilege(SE_SHUTDOWN_NAME, &local_err);
|
||||
execute_async(do_suspend, mode, &local_err);
|
||||
|
||||
if (error_is_set(err)) {
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
g_free(mode);
|
||||
}
|
||||
}
|
||||
|
||||
void qmp_guest_suspend_ram(Error **err)
|
||||
void qmp_guest_suspend_ram(Error **errp)
|
||||
{
|
||||
Error *local_err = NULL;
|
||||
GuestSuspendMode *mode = g_malloc(sizeof(GuestSuspendMode));
|
||||
|
||||
*mode = GUEST_SUSPEND_MODE_RAM;
|
||||
check_suspend_mode(*mode, err);
|
||||
acquire_privilege(SE_SHUTDOWN_NAME, err);
|
||||
execute_async(do_suspend, mode, err);
|
||||
check_suspend_mode(*mode, &local_err);
|
||||
acquire_privilege(SE_SHUTDOWN_NAME, &local_err);
|
||||
execute_async(do_suspend, mode, &local_err);
|
||||
|
||||
if (error_is_set(err)) {
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -372,6 +373,7 @@ int64_t qmp_guest_get_time(Error **errp)
|
||||
|
||||
void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)
|
||||
{
|
||||
Error *local_err = NULL;
|
||||
SYSTEMTIME ts;
|
||||
FILETIME tf;
|
||||
LONGLONG time;
|
||||
@@ -403,8 +405,9 @@ void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)
|
||||
}
|
||||
}
|
||||
|
||||
acquire_privilege(SE_SYSTEMTIME_NAME, errp);
|
||||
if (error_is_set(errp)) {
|
||||
acquire_privilege(SE_SYSTEMTIME_NAME, &local_err);
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -40,7 +40,7 @@ int64_t qmp_guest_sync(int64_t id, Error **errp)
|
||||
return id;
|
||||
}
|
||||
|
||||
void qmp_guest_ping(Error **err)
|
||||
void qmp_guest_ping(Error **errp)
|
||||
{
|
||||
slog("guest-ping called");
|
||||
}
|
||||
@@ -62,7 +62,7 @@ static void qmp_command_info(QmpCommand *cmd, void *opaque)
|
||||
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));
|
||||
|
||||
|
||||
@@ -910,6 +910,7 @@ int64_t ga_get_fd_handle(GAState *s, Error **errp)
|
||||
|
||||
if (!write_persistent_state(&s->pstate, s->pstate_filepath)) {
|
||||
error_setg(errp, "failed to commit persistent state to disk");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return handle;
|
||||
|
||||
+3
-3
@@ -145,19 +145,19 @@ void ga_uninstall_vss_provider(void)
|
||||
}
|
||||
|
||||
/* 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";
|
||||
QGAVSSRequesterFunc func;
|
||||
ErrorSet errset = {
|
||||
.error_set = (ErrorSetFunc)error_set_win32,
|
||||
.errp = (void **)err,
|
||||
.errp = (void **)errp,
|
||||
.err_class = ERROR_CLASS_GENERIC_ERROR
|
||||
};
|
||||
|
||||
func = (QGAVSSRequesterFunc)GetProcAddress(provider_lib, func_name);
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user