aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.objs1
-rw-r--r--backends/rng-random.c18
-rw-r--r--hmp.c28
-rw-r--r--hw/net/opencores_eth.c44
-rw-r--r--include/hw/virtio/virtio-rng.h2
-rw-r--r--include/migration/migration.h1
-rw-r--r--include/migration/qjson.h (renamed from include/qjson.h)2
-rw-r--r--include/migration/vmstate.h2
-rw-r--r--include/sysemu/rng-random.h4
-rw-r--r--migration/Makefile.objs1
-rw-r--r--migration/migration.c94
-rw-r--r--migration/qjson.c (renamed from qjson.c)58
-rw-r--r--migration/ram.c4
-rw-r--r--migration/savevm.c4
-rw-r--r--migration/vmstate.c1
-rw-r--r--qapi-schema.json54
-rw-r--r--qmp-commands.hx22
-rw-r--r--tests/Makefile2
18 files changed, 178 insertions, 164 deletions
diff --git a/Makefile.objs b/Makefile.objs
index 8f705f6..da49b71 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -52,7 +52,6 @@ common-obj-$(CONFIG_LINUX) += fsdev/
common-obj-y += migration/
common-obj-y += qemu-char.o #aio.o
common-obj-y += page_cache.o
-common-obj-y += qjson.o
common-obj-$(CONFIG_SPICE) += spice-qemu-char.o
diff --git a/backends/rng-random.c b/backends/rng-random.c
index 2e44e25..e2a49b0 100644
--- a/backends/rng-random.c
+++ b/backends/rng-random.c
@@ -17,7 +17,7 @@
#include "qapi/qmp/qerror.h"
#include "qemu/main-loop.h"
-struct RndRandom
+struct RngRandom
{
RngBackend parent;
@@ -34,7 +34,7 @@ struct RndRandom
static void entropy_available(void *opaque)
{
- RndRandom *s = RNG_RANDOM(opaque);
+ RngRandom *s = RNG_RANDOM(opaque);
while (!QSIMPLEQ_EMPTY(&s->parent.requests)) {
RngRequest *req = QSIMPLEQ_FIRST(&s->parent.requests);
@@ -57,7 +57,7 @@ static void entropy_available(void *opaque)
static void rng_random_request_entropy(RngBackend *b, RngRequest *req)
{
- RndRandom *s = RNG_RANDOM(b);
+ RngRandom *s = RNG_RANDOM(b);
if (QSIMPLEQ_EMPTY(&s->parent.requests)) {
/* If there are no pending requests yet, we need to
@@ -68,7 +68,7 @@ static void rng_random_request_entropy(RngBackend *b, RngRequest *req)
static void rng_random_opened(RngBackend *b, Error **errp)
{
- RndRandom *s = RNG_RANDOM(b);
+ RngRandom *s = RNG_RANDOM(b);
if (s->filename == NULL) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
@@ -83,7 +83,7 @@ static void rng_random_opened(RngBackend *b, Error **errp)
static char *rng_random_get_filename(Object *obj, Error **errp)
{
- RndRandom *s = RNG_RANDOM(obj);
+ RngRandom *s = RNG_RANDOM(obj);
return g_strdup(s->filename);
}
@@ -92,7 +92,7 @@ static void rng_random_set_filename(Object *obj, const char *filename,
Error **errp)
{
RngBackend *b = RNG_BACKEND(obj);
- RndRandom *s = RNG_RANDOM(obj);
+ RngRandom *s = RNG_RANDOM(obj);
if (b->opened) {
error_setg(errp, QERR_PERMISSION_DENIED);
@@ -105,7 +105,7 @@ static void rng_random_set_filename(Object *obj, const char *filename,
static void rng_random_init(Object *obj)
{
- RndRandom *s = RNG_RANDOM(obj);
+ RngRandom *s = RNG_RANDOM(obj);
object_property_add_str(obj, "filename",
rng_random_get_filename,
@@ -118,7 +118,7 @@ static void rng_random_init(Object *obj)
static void rng_random_finalize(Object *obj)
{
- RndRandom *s = RNG_RANDOM(obj);
+ RngRandom *s = RNG_RANDOM(obj);
if (s->fd != -1) {
qemu_set_fd_handler(s->fd, NULL, NULL, NULL);
@@ -139,7 +139,7 @@ static void rng_random_class_init(ObjectClass *klass, void *data)
static const TypeInfo rng_random_info = {
.name = TYPE_RNG_RANDOM,
.parent = TYPE_RNG_BACKEND,
- .instance_size = sizeof(RndRandom),
+ .instance_size = sizeof(RngRandom),
.class_init = rng_random_class_init,
.instance_init = rng_random_init,
.instance_finalize = rng_random_finalize,
diff --git a/hmp.c b/hmp.c
index d510236..9f9bcf9 100644
--- a/hmp.c
+++ b/hmp.c
@@ -235,9 +235,9 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict)
info->xbzrle_cache->overflow);
}
- if (info->has_x_cpu_throttle_percentage) {
+ if (info->has_cpu_throttle_percentage) {
monitor_printf(mon, "cpu throttle percentage: %" PRIu64 "\n",
- info->x_cpu_throttle_percentage);
+ info->cpu_throttle_percentage);
}
qapi_free_MigrationInfo(info);
@@ -281,11 +281,11 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)
MigrationParameter_lookup[MIGRATION_PARAMETER_DECOMPRESS_THREADS],
params->decompress_threads);
monitor_printf(mon, " %s: %" PRId64,
- MigrationParameter_lookup[MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL],
- params->x_cpu_throttle_initial);
+ MigrationParameter_lookup[MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL],
+ params->cpu_throttle_initial);
monitor_printf(mon, " %s: %" PRId64,
- MigrationParameter_lookup[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT],
- params->x_cpu_throttle_increment);
+ MigrationParameter_lookup[MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT],
+ params->cpu_throttle_increment);
monitor_printf(mon, "\n");
}
@@ -1240,8 +1240,8 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
bool has_compress_level = false;
bool has_compress_threads = false;
bool has_decompress_threads = false;
- bool has_x_cpu_throttle_initial = false;
- bool has_x_cpu_throttle_increment = false;
+ bool has_cpu_throttle_initial = false;
+ bool has_cpu_throttle_increment = false;
int i;
for (i = 0; i < MIGRATION_PARAMETER__MAX; i++) {
@@ -1256,18 +1256,18 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
case MIGRATION_PARAMETER_DECOMPRESS_THREADS:
has_decompress_threads = true;
break;
- case MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL:
- has_x_cpu_throttle_initial = true;
+ case MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL:
+ has_cpu_throttle_initial = true;
break;
- case MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT:
- has_x_cpu_throttle_increment = true;
+ case MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT:
+ has_cpu_throttle_increment = true;
break;
}
qmp_migrate_set_parameters(has_compress_level, value,
has_compress_threads, value,
has_decompress_threads, value,
- has_x_cpu_throttle_initial, value,
- has_x_cpu_throttle_increment, value,
+ has_cpu_throttle_initial, value,
+ has_cpu_throttle_increment, value,
&err);
break;
}
diff --git a/hw/net/opencores_eth.c b/hw/net/opencores_eth.c
index c6094fb..484d113 100644
--- a/hw/net/opencores_eth.c
+++ b/hw/net/opencores_eth.c
@@ -33,6 +33,7 @@
#include "qemu/osdep.h"
#include "hw/hw.h"
+#include "hw/net/mii.h"
#include "hw/sysbus.h"
#include "net/net.h"
#include "sysemu/sysemu.h"
@@ -55,12 +56,6 @@
/* PHY MII registers */
enum {
- MII_BMCR,
- MII_BMSR,
- MII_PHYIDR1,
- MII_PHYIDR2,
- MII_ANAR,
- MII_ANLPAR,
MII_REG_MAX = 16,
};
@@ -72,10 +67,11 @@ typedef struct Mii {
static void mii_set_link(Mii *s, bool link_ok)
{
if (link_ok) {
- s->regs[MII_BMSR] |= 0x4;
- s->regs[MII_ANLPAR] |= 0x01e1;
+ s->regs[MII_BMSR] |= MII_BMSR_LINK_ST;
+ s->regs[MII_ANLPAR] |= MII_ANLPAR_TXFD | MII_ANLPAR_TX |
+ MII_ANLPAR_10FD | MII_ANLPAR_10 | MII_ANLPAR_CSMACD;
} else {
- s->regs[MII_BMSR] &= ~0x4;
+ s->regs[MII_BMSR] &= ~MII_BMSR_LINK_ST;
s->regs[MII_ANLPAR] &= 0x01ff;
}
s->link_ok = link_ok;
@@ -84,11 +80,14 @@ static void mii_set_link(Mii *s, bool link_ok)
static void mii_reset(Mii *s)
{
memset(s->regs, 0, sizeof(s->regs));
- s->regs[MII_BMCR] = 0x1000;
- s->regs[MII_BMSR] = 0x7868; /* no ext regs */
- s->regs[MII_PHYIDR1] = 0x2000;
- s->regs[MII_PHYIDR2] = 0x5c90;
- s->regs[MII_ANAR] = 0x01e1;
+ s->regs[MII_BMCR] = MII_BMCR_AUTOEN;
+ s->regs[MII_BMSR] = MII_BMSR_100TX_FD | MII_BMSR_100TX_HD |
+ MII_BMSR_10T_FD | MII_BMSR_10T_HD | MII_BMSR_MFPS |
+ MII_BMSR_AN_COMP | MII_BMSR_AUTONEG;
+ s->regs[MII_PHYID1] = 0x2000;
+ s->regs[MII_PHYID2] = 0x5c90;
+ s->regs[MII_ANAR] = MII_ANAR_TXFD | MII_ANAR_TX |
+ MII_ANAR_10FD | MII_ANAR_10 | MII_ANAR_CSMACD;
mii_set_link(s, s->link_ok);
}
@@ -98,7 +97,7 @@ static void mii_ro(Mii *s, uint16_t v)
static void mii_write_bmcr(Mii *s, uint16_t v)
{
- if (v & 0x8000) {
+ if (v & MII_BMCR_RESET) {
mii_reset(s);
} else {
s->regs[MII_BMCR] = v;
@@ -110,8 +109,8 @@ static void mii_write_host(Mii *s, unsigned idx, uint16_t v)
static void (*reg_write[MII_REG_MAX])(Mii *s, uint16_t v) = {
[MII_BMCR] = mii_write_bmcr,
[MII_BMSR] = mii_ro,
- [MII_PHYIDR1] = mii_ro,
- [MII_PHYIDR2] = mii_ro,
+ [MII_PHYID1] = mii_ro,
+ [MII_PHYID2] = mii_ro,
};
if (idx < MII_REG_MAX) {
@@ -483,7 +482,8 @@ static NetClientInfo net_open_eth_info = {
static void open_eth_start_xmit(OpenEthState *s, desc *tx)
{
- uint8_t buf[65536];
+ uint8_t *buf = NULL;
+ uint8_t buffer[0x600];
unsigned len = GET_FIELD(tx->len_flags, TXD_LEN);
unsigned tx_len = len;
@@ -498,6 +498,11 @@ static void open_eth_start_xmit(OpenEthState *s, desc *tx)
trace_open_eth_start_xmit(tx->buf_ptr, len, tx_len);
+ if (tx_len > sizeof(buffer)) {
+ buf = g_new(uint8_t, tx_len);
+ } else {
+ buf = buffer;
+ }
if (len > tx_len) {
len = tx_len;
}
@@ -506,6 +511,9 @@ static void open_eth_start_xmit(OpenEthState *s, desc *tx)
memset(buf + len, 0, tx_len - len);
}
qemu_send_packet(qemu_get_queue(s->nic), buf, tx_len);
+ if (tx_len > sizeof(buffer)) {
+ g_free(buf);
+ }
if (tx->len_flags & TXD_WR) {
s->tx_desc = 0;
diff --git a/include/hw/virtio/virtio-rng.h b/include/hw/virtio/virtio-rng.h
index 3f07de7..2bc1ee5 100644
--- a/include/hw/virtio/virtio-rng.h
+++ b/include/hw/virtio/virtio-rng.h
@@ -26,7 +26,7 @@ struct VirtIORNGConf {
RngBackend *rng;
uint64_t max_bytes;
uint32_t period_ms;
- RndRandom *default_backend;
+ RngRandom *default_backend;
};
typedef struct VirtIORNG {
diff --git a/include/migration/migration.h b/include/migration/migration.h
index ac2c12c..9e36a97 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -210,6 +210,7 @@ int migrate_fd_close(MigrationState *s);
void add_migration_state_change_notifier(Notifier *notify);
void remove_migration_state_change_notifier(Notifier *notify);
MigrationState *migrate_init(const MigrationParams *params);
+bool migration_is_blocked(Error **errp);
bool migration_in_setup(MigrationState *);
bool migration_has_finished(MigrationState *);
bool migration_has_failed(MigrationState *);
diff --git a/include/qjson.h b/include/migration/qjson.h
index 7c54fdf..2978b5f 100644
--- a/include/qjson.h
+++ b/include/migration/qjson.h
@@ -13,10 +13,10 @@
#ifndef QEMU_QJSON_H
#define QEMU_QJSON_H
-#define TYPE_QJSON "QJSON"
typedef struct QJSON QJSON;
QJSON *qjson_new(void);
+void qjson_destroy(QJSON *json);
void json_prop_str(QJSON *json, const char *name, const char *str);
void json_prop_int(QJSON *json, const char *name, int64_t val);
void json_end_array(QJSON *json);
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 84ee355..30ecc44 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -29,7 +29,7 @@
#ifndef CONFIG_USER_ONLY
#include <migration/qemu-file.h>
#endif
-#include <qjson.h>
+#include "migration/qjson.h"
typedef void SaveStateHandler(QEMUFile *f, void *opaque);
typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id);
diff --git a/include/sysemu/rng-random.h b/include/sysemu/rng-random.h
index 4332772..38186fe 100644
--- a/include/sysemu/rng-random.h
+++ b/include/sysemu/rng-random.h
@@ -15,8 +15,8 @@
#include "qom/object.h"
#define TYPE_RNG_RANDOM "rng-random"
-#define RNG_RANDOM(obj) OBJECT_CHECK(RndRandom, (obj), TYPE_RNG_RANDOM)
+#define RNG_RANDOM(obj) OBJECT_CHECK(RngRandom, (obj), TYPE_RNG_RANDOM)
-typedef struct RndRandom RndRandom;
+typedef struct RngRandom RngRandom;
#endif
diff --git a/migration/Makefile.objs b/migration/Makefile.objs
index 0cac6d7..d25ff48 100644
--- a/migration/Makefile.objs
+++ b/migration/Makefile.objs
@@ -2,6 +2,7 @@ common-obj-y += migration.o tcp.o
common-obj-y += vmstate.o
common-obj-y += qemu-file.o qemu-file-buf.o qemu-file-unix.o qemu-file-stdio.o
common-obj-y += xbzrle.o postcopy-ram.o
+common-obj-y += qjson.o
common-obj-$(CONFIG_RDMA) += rdma.o
common-obj-$(CONFIG_POSIX) += exec.o unix.o fd.o
diff --git a/migration/migration.c b/migration/migration.c
index c08d9a6..f5327e8 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -50,8 +50,8 @@
/*0: means nocompress, 1: best speed, ... 9: best compress ratio */
#define DEFAULT_MIGRATE_COMPRESS_LEVEL 1
/* Define default autoconverge cpu throttle migration parameters */
-#define DEFAULT_MIGRATE_X_CPU_THROTTLE_INITIAL 20
-#define DEFAULT_MIGRATE_X_CPU_THROTTLE_INCREMENT 10
+#define DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL 20
+#define DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT 10
/* Migration XBZRLE default cache size */
#define DEFAULT_MIGRATE_CACHE_SIZE (64 * 1024 * 1024)
@@ -87,10 +87,10 @@ MigrationState *migrate_get_current(void)
DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT,
.parameters[MIGRATION_PARAMETER_DECOMPRESS_THREADS] =
DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT,
- .parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL] =
- DEFAULT_MIGRATE_X_CPU_THROTTLE_INITIAL,
- .parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT] =
- DEFAULT_MIGRATE_X_CPU_THROTTLE_INCREMENT,
+ .parameters[MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL] =
+ DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL,
+ .parameters[MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT] =
+ DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT,
};
if (!once) {
@@ -521,10 +521,10 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp)
s->parameters[MIGRATION_PARAMETER_COMPRESS_THREADS];
params->decompress_threads =
s->parameters[MIGRATION_PARAMETER_DECOMPRESS_THREADS];
- params->x_cpu_throttle_initial =
- s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL];
- params->x_cpu_throttle_increment =
- s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT];
+ params->cpu_throttle_initial =
+ s->parameters[MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL];
+ params->cpu_throttle_increment =
+ s->parameters[MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT];
return params;
}
@@ -607,8 +607,8 @@ MigrationInfo *qmp_query_migrate(Error **errp)
}
if (cpu_throttle_active()) {
- info->has_x_cpu_throttle_percentage = true;
- info->x_cpu_throttle_percentage = cpu_throttle_get_percentage();
+ info->has_cpu_throttle_percentage = true;
+ info->cpu_throttle_percentage = cpu_throttle_get_percentage();
}
get_xbzrle_cache_stats(info);
@@ -718,10 +718,10 @@ void qmp_migrate_set_parameters(bool has_compress_level,
int64_t compress_threads,
bool has_decompress_threads,
int64_t decompress_threads,
- bool has_x_cpu_throttle_initial,
- int64_t x_cpu_throttle_initial,
- bool has_x_cpu_throttle_increment,
- int64_t x_cpu_throttle_increment, Error **errp)
+ bool has_cpu_throttle_initial,
+ int64_t cpu_throttle_initial,
+ bool has_cpu_throttle_increment,
+ int64_t cpu_throttle_increment, Error **errp)
{
MigrationState *s = migrate_get_current();
@@ -744,16 +744,16 @@ void qmp_migrate_set_parameters(bool has_compress_level,
"is invalid, it should be in the range of 1 to 255");
return;
}
- if (has_x_cpu_throttle_initial &&
- (x_cpu_throttle_initial < 1 || x_cpu_throttle_initial > 99)) {
+ if (has_cpu_throttle_initial &&
+ (cpu_throttle_initial < 1 || cpu_throttle_initial > 99)) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
- "x_cpu_throttle_initial",
+ "cpu_throttle_initial",
"an integer in the range of 1 to 99");
}
- if (has_x_cpu_throttle_increment &&
- (x_cpu_throttle_increment < 1 || x_cpu_throttle_increment > 99)) {
+ if (has_cpu_throttle_increment &&
+ (cpu_throttle_increment < 1 || cpu_throttle_increment > 99)) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
- "x_cpu_throttle_increment",
+ "cpu_throttle_increment",
"an integer in the range of 1 to 99");
}
@@ -767,14 +767,14 @@ void qmp_migrate_set_parameters(bool has_compress_level,
s->parameters[MIGRATION_PARAMETER_DECOMPRESS_THREADS] =
decompress_threads;
}
- if (has_x_cpu_throttle_initial) {
- s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL] =
- x_cpu_throttle_initial;
+ if (has_cpu_throttle_initial) {
+ s->parameters[MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL] =
+ cpu_throttle_initial;
}
- if (has_x_cpu_throttle_increment) {
- s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT] =
- x_cpu_throttle_increment;
+ if (has_cpu_throttle_increment) {
+ s->parameters[MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT] =
+ cpu_throttle_increment;
}
}
@@ -992,6 +992,20 @@ void qmp_migrate_incoming(const char *uri, Error **errp)
once = false;
}
+bool migration_is_blocked(Error **errp)
+{
+ if (qemu_savevm_state_blocked(errp)) {
+ return true;
+ }
+
+ if (migration_blockers) {
+ *errp = error_copy(migration_blockers->data);
+ return true;
+ }
+
+ return false;
+}
+
void qmp_migrate(const char *uri, bool has_blk, bool blk,
bool has_inc, bool inc, bool has_detach, bool detach,
Error **errp)
@@ -1014,12 +1028,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
return;
}
- if (qemu_savevm_state_blocked(errp)) {
- return;
- }
-
- if (migration_blockers) {
- *errp = error_copy(migration_blockers->data);
+ if (migration_is_blocked(errp)) {
return;
}
@@ -1597,19 +1606,32 @@ static void migration_completion(MigrationState *s, int current_active_state,
rp_error = await_return_path_close_on_source(s);
trace_migration_completion_postcopy_end_after_rp(rp_error);
if (rp_error) {
- goto fail;
+ goto fail_invalidate;
}
}
if (qemu_file_get_error(s->to_dst_file)) {
trace_migration_completion_file_err();
- goto fail;
+ goto fail_invalidate;
}
migrate_set_state(&s->state, current_active_state,
MIGRATION_STATUS_COMPLETED);
return;
+fail_invalidate:
+ /* If not doing postcopy, vm_start() will be called: let's regain
+ * control on images.
+ */
+ if (s->state == MIGRATION_STATUS_ACTIVE) {
+ Error *local_err = NULL;
+
+ bdrv_invalidate_cache_all(&local_err);
+ if (local_err) {
+ error_report_err(local_err);
+ }
+ }
+
fail:
migrate_set_state(&s->state, current_active_state,
MIGRATION_STATUS_FAILED);
diff --git a/qjson.c b/migration/qjson.c
index b65ca6e..5cae55a 100644
--- a/qjson.c
+++ b/migration/qjson.c
@@ -1,5 +1,5 @@
/*
- * QEMU JSON writer
+ * A simple JSON writer
*
* Copyright Alexander Graf
*
@@ -11,21 +11,27 @@
*
*/
+/*
+ * Type QJSON lets you build JSON text. Its interface mirrors (a
+ * subset of) abstract JSON syntax.
+ *
+ * It does *not* detect incorrect use. It happily produces invalid
+ * JSON then. This is what migration wants.
+ *
+ * QAPI output visitors also produce JSON text. However, they do
+ * assert their preconditions and invariants, and therefore abort on
+ * incorrect use.
+ */
+
#include "qemu/osdep.h"
-#include <qapi/qmp/qstring.h>
-#include <glib.h>
-#include <qjson.h>
-#include <qemu/module.h>
-#include <qom/object.h>
+#include "qapi/qmp/qstring.h"
+#include "migration/qjson.h"
struct QJSON {
- Object obj;
QString *str;
bool omit_comma;
};
-#define QJSON(obj) OBJECT_CHECK(QJSON, (obj), TYPE_QJSON)
-
static void json_emit_element(QJSON *json, const char *name)
{
/* Check whether we need to print a , before an element */
@@ -89,41 +95,19 @@ const char *qjson_get_str(QJSON *json)
QJSON *qjson_new(void)
{
- QJSON *json = QJSON(object_new(TYPE_QJSON));
- return json;
-}
-
-void qjson_finish(QJSON *json)
-{
- json_end_object(json);
-}
-
-static void qjson_initfn(Object *obj)
-{
- QJSON *json = QJSON(obj);
+ QJSON *json = g_new0(QJSON, 1);
json->str = qstring_from_str("{ ");
json->omit_comma = true;
+ return json;
}
-static void qjson_finalizefn(Object *obj)
+void qjson_finish(QJSON *json)
{
- QJSON *json = QJSON(obj);
-
- qobject_decref(QOBJECT(json->str));
+ json_end_object(json);
}
-static const TypeInfo qjson_type_info = {
- .name = TYPE_QJSON,
- .parent = TYPE_OBJECT,
- .instance_size = sizeof(QJSON),
- .instance_init = qjson_initfn,
- .instance_finalize = qjson_finalizefn,
-};
-
-static void qjson_register_types(void)
+void qjson_destroy(QJSON *json)
{
- type_register_static(&qjson_type_info);
+ g_free(json);
}
-
-type_init(qjson_register_types)
diff --git a/migration/ram.c b/migration/ram.c
index 6b6900e..54e2151 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -430,9 +430,9 @@ static void mig_throttle_guest_down(void)
{
MigrationState *s = migrate_get_current();
uint64_t pct_initial =
- s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL];
+ s->parameters[MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL];
uint64_t pct_icrement =
- s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT];
+ s->parameters[MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT];
/* We have not started throttling yet. Let's start it. */
if (!cpu_throttle_active()) {
diff --git a/migration/savevm.c b/migration/savevm.c
index 9bc362a..65ce0c6 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1115,7 +1115,7 @@ void qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only)
qemu_put_be32(f, vmdesc_len);
qemu_put_buffer(f, (uint8_t *)qjson_get_str(vmdesc), vmdesc_len);
}
- object_unref(OBJECT(vmdesc));
+ qjson_destroy(vmdesc);
qemu_fflush(f);
}
@@ -1170,7 +1170,7 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
MigrationState *ms = migrate_init(&params);
ms->to_dst_file = f;
- if (qemu_savevm_state_blocked(errp)) {
+ if (migration_is_blocked(errp)) {
return -EINVAL;
}
diff --git a/migration/vmstate.c b/migration/vmstate.c
index bf3d5db..46dc55e 100644
--- a/migration/vmstate.c
+++ b/migration/vmstate.c
@@ -6,7 +6,6 @@
#include "qemu/bitops.h"
#include "qemu/error-report.h"
#include "trace.h"
-#include "qjson.h"
static void vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd,
void *opaque, QJSON *vmdesc);
diff --git a/qapi-schema.json b/qapi-schema.json
index 54634c4..9a322d1 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -480,9 +480,9 @@
# may be expensive, but do not actually occur during the iterative
# migration rounds themselves. (since 1.6)
#
-# @x-cpu-throttle-percentage: #optional percentage of time guest cpus are being
-# throttled during auto-converge. This is only present when auto-converge
-# has started throttling guest cpus. (Since 2.5)
+# @cpu-throttle-percentage: #optional percentage of time guest cpus are being
+# throttled during auto-converge. This is only present when auto-converge
+# has started throttling guest cpus. (Since 2.7)
#
# Since: 0.14.0
##
@@ -494,7 +494,7 @@
'*expected-downtime': 'int',
'*downtime': 'int',
'*setup-time': 'int',
- '*x-cpu-throttle-percentage': 'int'} }
+ '*cpu-throttle-percentage': 'int'} }
##
# @query-migrate
@@ -605,18 +605,18 @@
# compression, so set the decompress-threads to the number about 1/4
# of compress-threads is adequate.
#
-# @x-cpu-throttle-initial: Initial percentage of time guest cpus are throttled
-# when migration auto-converge is activated. The
-# default value is 20. (Since 2.5)
+# @cpu-throttle-initial: Initial percentage of time guest cpus are throttled
+# when migration auto-converge is activated. The
+# default value is 20. (Since 2.7)
#
-# @x-cpu-throttle-increment: throttle percentage increase each time
-# auto-converge detects that migration is not making
-# progress. The default value is 10. (Since 2.5)
+# @cpu-throttle-increment: throttle percentage increase each time
+# auto-converge detects that migration is not making
+# progress. The default value is 10. (Since 2.7)
# Since: 2.4
##
{ 'enum': 'MigrationParameter',
'data': ['compress-level', 'compress-threads', 'decompress-threads',
- 'x-cpu-throttle-initial', 'x-cpu-throttle-increment'] }
+ 'cpu-throttle-initial', 'cpu-throttle-increment'] }
#
# @migrate-set-parameters
@@ -629,21 +629,21 @@
#
# @decompress-threads: decompression thread count
#
-# @x-cpu-throttle-initial: Initial percentage of time guest cpus are throttled
-# when migration auto-converge is activated. The
-# default value is 20. (Since 2.5)
+# @cpu-throttle-initial: Initial percentage of time guest cpus are throttled
+# when migration auto-converge is activated. The
+# default value is 20. (Since 2.7)
#
-# @x-cpu-throttle-increment: throttle percentage increase each time
-# auto-converge detects that migration is not making
-# progress. The default value is 10. (Since 2.5)
+# @cpu-throttle-increment: throttle percentage increase each time
+# auto-converge detects that migration is not making
+# progress. The default value is 10. (Since 2.7)
# Since: 2.4
##
{ 'command': 'migrate-set-parameters',
'data': { '*compress-level': 'int',
'*compress-threads': 'int',
'*decompress-threads': 'int',
- '*x-cpu-throttle-initial': 'int',
- '*x-cpu-throttle-increment': 'int'} }
+ '*cpu-throttle-initial': 'int',
+ '*cpu-throttle-increment': 'int'} }
#
# @MigrationParameters
@@ -654,13 +654,13 @@
#
# @decompress-threads: decompression thread count
#
-# @x-cpu-throttle-initial: Initial percentage of time guest cpus are throttled
-# when migration auto-converge is activated. The
-# default value is 20. (Since 2.5)
+# @cpu-throttle-initial: Initial percentage of time guest cpus are throttled
+# when migration auto-converge is activated. The
+# default value is 20. (Since 2.7)
#
-# @x-cpu-throttle-increment: throttle percentage increase each time
-# auto-converge detects that migration is not making
-# progress. The default value is 10. (Since 2.5)
+# @cpu-throttle-increment: throttle percentage increase each time
+# auto-converge detects that migration is not making
+# progress. The default value is 10. (Since 2.7)
#
# Since: 2.4
##
@@ -668,8 +668,8 @@
'data': { 'compress-level': 'int',
'compress-threads': 'int',
'decompress-threads': 'int',
- 'x-cpu-throttle-initial': 'int',
- 'x-cpu-throttle-increment': 'int'} }
+ 'cpu-throttle-initial': 'int',
+ 'cpu-throttle-increment': 'int'} }
##
# @query-migrate-parameters
#
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 94847e5..28801a2 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -3747,10 +3747,10 @@ Set migration parameters
- "compress-level": set compression level during migration (json-int)
- "compress-threads": set compression thread count for migration (json-int)
- "decompress-threads": set decompression thread count for migration (json-int)
-- "x-cpu-throttle-initial": set initial percentage of time guest cpus are
- throttled for auto-converge (json-int)
-- "x-cpu-throttle-increment": set throttle increasing percentage for
- auto-converge (json-int)
+- "cpu-throttle-initial": set initial percentage of time guest cpus are
+ throttled for auto-converge (json-int)
+- "cpu-throttle-increment": set throttle increasing percentage for
+ auto-converge (json-int)
Arguments:
@@ -3764,7 +3764,7 @@ EQMP
{
.name = "migrate-set-parameters",
.args_type =
- "compress-level:i?,compress-threads:i?,decompress-threads:i?,x-cpu-throttle-initial:i?,x-cpu-throttle-increment:i?",
+ "compress-level:i?,compress-threads:i?,decompress-threads:i?,cpu-throttle-initial:i?,cpu-throttle-increment:i?",
.mhandler.cmd_new = qmp_marshal_migrate_set_parameters,
},
SQMP
@@ -3777,10 +3777,10 @@ Query current migration parameters
- "compress-level" : compression level value (json-int)
- "compress-threads" : compression thread count value (json-int)
- "decompress-threads" : decompression thread count value (json-int)
- - "x-cpu-throttle-initial" : initial percentage of time guest cpus are
- throttled (json-int)
- - "x-cpu-throttle-increment" : throttle increasing percentage for
- auto-converge (json-int)
+ - "cpu-throttle-initial" : initial percentage of time guest cpus are
+ throttled (json-int)
+ - "cpu-throttle-increment" : throttle increasing percentage for
+ auto-converge (json-int)
Arguments:
@@ -3790,10 +3790,10 @@ Example:
<- {
"return": {
"decompress-threads": 2,
- "x-cpu-throttle-increment": 10,
+ "cpu-throttle-increment": 10,
"compress-threads": 8,
"compress-level": 1,
- "x-cpu-throttle-initial": 20
+ "cpu-throttle-initial": 20
}
}
diff --git a/tests/Makefile b/tests/Makefile
index 9dddde6..1bbd1ca 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -439,7 +439,7 @@ tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \
$(test-qapi-obj-y)
tests/test-vmstate$(EXESUF): tests/test-vmstate.o \
migration/vmstate.o migration/qemu-file.o migration/qemu-file-buf.o \
- migration/qemu-file-unix.o qjson.o \
+ migration/qemu-file-unix.o migration/qjson.o \
$(test-qom-obj-y)
tests/test-timed-average$(EXESUF): tests/test-timed-average.o qemu-timer.o \
$(test-util-obj-y)