Re: [Qemu-devel] To measure Interrupt latency

2014-05-31 Thread saravanakumar punith
On Fri, May 30, 2014 at 8:26 PM, saravanakumar punith
 wrote:
>
> Hi,
> Is there any way to measure interrupt latency ( delay between interrupt 
> occurred and interrupt service routine is getting called) in VM.
>
> Consider a device is assigned to a VM (using passthrough).
> Now, interrupt is triggered for the device.
>
> I believe kernel code in Host side is getting called first and then  
> corresponding interrupt handler
> registered in Guest side is getting called.
>
> Now , I would like to measure the latency between
> a. interrupt notification at host side
> b. Actual interrupt handler called at Guest side
>
> Is there a (software)method exists to measure interrupt latency for a device 
> inside VM.?
> Architecutre : X86_64 and qemu-kvm used.
>
> PS:
> I read about using some high precision timer and measure time difference.
> But I am not sure whether it is possible to access the timer from  Host and 
> Guest and measure the latency.
>
> Please let me know.
> Thanks
>
>
>

Can someone help ?

Thanks



[Qemu-devel] [PATCH v3 0/3] e1000: allow model/device_id selection on command line

2014-05-31 Thread Gabriel L. Somlo
Allow selection of different card models from the qemu
command line, to better accomodate a wider range of guests.

New in v3:

  - 1/3 and 2/3 from v2 now merged into a single patch (1/3), with:
  - s/TYPE_E1000/TYPE_E1000_BASE/ as suggested by Stefan
  - improved QOM-ification as suggested by Peter Crosthwaite

  - *OPTIONAL* patch to remove stale support for 8257xx (see commit blurb
in patch 3/3 for details
(this can be squashed on top of 1/3, but I'm including it separately
 here for clarity, and as an RFC).

Thanks,
  Gabriel


v2:

  - moved check for 8257x out of the way of QOM, as suggested by
Michael (patch 1/3)

  - resolved "Signed-off-by" misunderstanding and miscellaneous style
issues (patch 2/3)

  - modified e1000 test to check for all supported models, as suggested
by Andreas (patch 3/3). I used eepro100-test.c as an example for
this change.


Gabriel L. Somlo (3):
  e1000: allow command-line selection of card model
  tests: e1000: test additional device IDs
  e1000: remove broken support for 82573L

 hw/net/e1000.c  | 110 +++-
 hw/net/e1000_regs.h |   6 +++
 tests/e1000-test.c  |  33 
 3 files changed, 114 insertions(+), 35 deletions(-)

-- 
1.9.3




[Qemu-devel] [PATCH v3 3/3] e1000: remove broken support for 82573L

2014-05-31 Thread Gabriel L. Somlo
Currently, e1000 support is based on the manual for the 8254xx
model series. 82573x models are documented in a separate manual
(see 
http://www.intel.com/content/dam/www/public/us/en/documents/manuals/pcie-gbe-controllers-open-source-manual.pdf)
and the 82573L device ID no longer works correctly on either Linux
(3.14.*) or Windows 7.

This patch removes stale code claiming to support 82573L, cleaning
up the code base for the remaining 8254xx model series.

Signed-off-by: Gabriel Somlo 
---
 hw/net/e1000.c | 18 --
 tests/e1000-test.c |  1 -
 2 files changed, 19 deletions(-)

diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index 4e208e3..3ae5b43 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -70,8 +70,6 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
 /*
  * HW models:
  *  E1000_DEV_ID_82540EM works with Windows, Linux, and OS X <= 10.8
- *  E1000_DEV_ID_82573L OK with windoze and Linux 2.6.22,
- * appears to perform better than 82540EM, but breaks with Linux 2.6.18
  *  E1000_DEV_ID_82544GC_COPPER appears to work; not well tested
  *  E1000_DEV_ID_82545EM_COPPER works with Linux and OS X >= 10.6
  *  Others never tested
@@ -144,7 +142,6 @@ typedef struct E1000State_st {
 typedef struct E1000DeviceClass {
 PCIDeviceClass parent_class;
 uint16_t phy_id2;
-bool is_8257xx;
 } E1000DeviceClass;
 
 #define TYPE_E1000_BASE "e1000-base"
@@ -271,15 +268,9 @@ static void
 set_interrupt_cause(E1000State *s, int index, uint32_t val)
 {
 PCIDevice *d = PCI_DEVICE(s);
-E1000DeviceClass *edc = E1000_DEVICE_GET_CLASS(d);
 uint32_t pending_ints;
 uint32_t mit_delay;
 
-if (val && edc->is_8257xx) {
-/* hack only for 8257xx models */
-val |= E1000_ICR_INT_ASSERTED;
-}
-
 s->mac_reg[ICR] = val;
 
 /*
@@ -1581,7 +1572,6 @@ typedef struct E1000Info_st {
 uint16_t   device_id;
 uint8_trevision;
 uint16_t   phy_id2;
-bool   is_8257xx;
 } E1000Info;
 
 static void e1000_class_init(ObjectClass *klass, void *data)
@@ -1598,7 +1588,6 @@ static void e1000_class_init(ObjectClass *klass, void 
*data)
 k->device_id = info->device_id;
 k->revision = info->revision;
 e->phy_id2 = info->phy_id2;
-e->is_8257xx = info->is_8257xx;
 k->class_id = PCI_CLASS_NETWORK_ETHERNET;
 set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
 dc->desc = "Intel Gigabit Ethernet";
@@ -1634,13 +1623,6 @@ static const E1000Info e1000_devices[] = {
 .revision  = 0x03,
 .phy_id2   = E1000_PHY_ID2_8254xx_DEFAULT,
 },
-{
-.name  = "e1000-82573l",
-.device_id = E1000_DEV_ID_82573L,
-.revision  = 0x03,
-.phy_id2   = E1000_PHY_ID2_82573x,
-.is_8257xx = true,
-},
 };
 
 static const TypeInfo e1000_default_info = {
diff --git a/tests/e1000-test.c b/tests/e1000-test.c
index 53c41f8..81f164d 100644
--- a/tests/e1000-test.c
+++ b/tests/e1000-test.c
@@ -33,7 +33,6 @@ static const char *models[] = {
 "e1000-82540em",
 "e1000-82544gc",
 "e1000-82545em",
-"e1000-82573l",
 };
 
 int main(int argc, char **argv)
-- 
1.9.3




[Qemu-devel] [PATCH v3 1/3] e1000: allow command-line selection of card model

2014-05-31 Thread Gabriel L. Somlo
Allow selection of different card models from the qemu
command line, to better accomodate a wider range of guests.

Signed-off-by: Romain Dolbeau 
Signed-off-by: Gabriel Somlo 
---
 hw/net/e1000.c  | 120 +---
 hw/net/e1000_regs.h |   6 +++
 2 files changed, 102 insertions(+), 24 deletions(-)

diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index 8387443..4e208e3 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -69,23 +69,13 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
 
 /*
  * HW models:
- *  E1000_DEV_ID_82540EM works with Windows and Linux
+ *  E1000_DEV_ID_82540EM works with Windows, Linux, and OS X <= 10.8
  *  E1000_DEV_ID_82573L OK with windoze and Linux 2.6.22,
  * appears to perform better than 82540EM, but breaks with Linux 2.6.18
  *  E1000_DEV_ID_82544GC_COPPER appears to work; not well tested
+ *  E1000_DEV_ID_82545EM_COPPER works with Linux and OS X >= 10.6
  *  Others never tested
  */
-enum { E1000_DEVID = E1000_DEV_ID_82540EM };
-
-/*
- * May need to specify additional MAC-to-PHY entries --
- * Intel's Windows driver refuses to initialize unless they match
- */
-enum {
-PHY_ID2_INIT = E1000_DEVID == E1000_DEV_ID_82573L ?0xcc2 :
-   E1000_DEVID == E1000_DEV_ID_82544GC_COPPER ?0xc30 :
-   /* default to E1000_DEV_ID_82540EM */   0xc20
-};
 
 typedef struct E1000State_st {
 /*< private >*/
@@ -151,10 +141,21 @@ typedef struct E1000State_st {
 uint32_t compat_flags;
 } E1000State;
 
-#define TYPE_E1000 "e1000"
+typedef struct E1000DeviceClass {
+PCIDeviceClass parent_class;
+uint16_t phy_id2;
+bool is_8257xx;
+} E1000DeviceClass;
+
+#define TYPE_E1000_BASE "e1000-base"
 
 #define E1000(obj) \
-OBJECT_CHECK(E1000State, (obj), TYPE_E1000)
+OBJECT_CHECK(E1000State, (obj), TYPE_E1000_BASE)
+
+#define E1000_DEVICE_CLASS(klass) \
+ OBJECT_CLASS_CHECK(E1000DeviceClass, (klass), TYPE_E1000_BASE)
+#define E1000_DEVICE_GET_CLASS(obj) \
+OBJECT_GET_CLASS(E1000DeviceClass, (obj), TYPE_E1000_BASE)
 
 #definedefreg(x)   x = (E1000_##x>>2)
 enum {
@@ -232,10 +233,11 @@ static const char phy_regcap[0x20] = {
 [PHY_ID2] = PHY_R, [M88E1000_PHY_SPEC_STATUS] = PHY_R
 };
 
+/* PHY_ID2 documented in 8254x_GBe_SDM.pdf, pp. 250 */
 static const uint16_t phy_reg_init[] = {
 [PHY_CTRL] = 0x1140,
 [PHY_STATUS] = 0x794d, /* link initially up with not completed autoneg */
-[PHY_ID1] = 0x141, [PHY_ID2] = PHY_ID2_INIT,
+[PHY_ID1] = 0x141, /* [PHY_ID2] configured per DevId, from e1000_reset() */
 [PHY_1000T_CTRL] = 0x0e00, [M88E1000_PHY_SPEC_CTRL] = 
0x360,
 [M88E1000_EXT_PHY_SPEC_CTRL] = 0x0d60, [PHY_AUTONEG_ADV] = 0xde1,
 [PHY_LP_ABILITY] = 0x1e0,  [PHY_1000T_STATUS] = 0x3c00,
@@ -269,13 +271,15 @@ static void
 set_interrupt_cause(E1000State *s, int index, uint32_t val)
 {
 PCIDevice *d = PCI_DEVICE(s);
+E1000DeviceClass *edc = E1000_DEVICE_GET_CLASS(d);
 uint32_t pending_ints;
 uint32_t mit_delay;
 
-if (val && (E1000_DEVID >= E1000_DEV_ID_82547EI_MOBILE)) {
-/* Only for 8257x */
+if (val && edc->is_8257xx) {
+/* hack only for 8257xx models */
 val |= E1000_ICR_INT_ASSERTED;
 }
+
 s->mac_reg[ICR] = val;
 
 /*
@@ -375,6 +379,7 @@ rxbufsize(uint32_t v)
 static void e1000_reset(void *opaque)
 {
 E1000State *d = opaque;
+E1000DeviceClass *edc = E1000_DEVICE_GET_CLASS(d);
 uint8_t *macaddr = d->conf.macaddr.a;
 int i;
 
@@ -385,6 +390,7 @@ static void e1000_reset(void *opaque)
 d->mit_ide = 0;
 memset(d->phy_reg, 0, sizeof d->phy_reg);
 memmove(d->phy_reg, phy_reg_init, sizeof phy_reg_init);
+d->phy_reg[PHY_ID2] = edc->phy_id2;
 memset(d->mac_reg, 0, sizeof d->mac_reg);
 memmove(d->mac_reg, mac_reg_init, sizeof mac_reg_init);
 d->rxbuf_min_shift = 1;
@@ -1440,9 +1446,13 @@ static const VMStateDescription vmstate_e1000 = {
 }
 };
 
+/*
+ * EEPROM contents documented in Tables 5-2 and 5-3, pp. 98-102.
+ * Note: A valid DevId will be inserted during pci_e1000_init().
+ */
 static const uint16_t e1000_eeprom_template[64] = {
 0x, 0x, 0x, 0x,  0x, 0x,  0x, 0x,
-0x3000, 0x1000, 0x6403, E1000_DEVID, 0x8086, E1000_DEVID, 0x8086, 0x3040,
+0x3000, 0x1000, 0x6403, 0 /*DevId*/, 0x8086, 0 /*DevId*/, 0x8086, 0x3040,
 0x0008, 0x2000, 0x7e14, 0x0048,  0x1000, 0x00d8,  0x, 0x2700,
 0x6cc9, 0x3150, 0x0722, 0x040b,  0x0984, 0x,  0xc000, 0x0706,
 0x1008, 0x, 0x0f04, 0x7fff,  0x4d01, 0x,  0x, 0x,
@@ -1507,6 +1517,7 @@ static int pci_e1000_init(PCIDevice *pci_dev)
 {
 DeviceState *dev = DEVICE(pci_dev);
 E1000State *d = E1000(pci_dev);
+PCIDeviceClass *pdc = PCI_DEVICE_GET_CLASS(pci_dev);
 uint8_t *pci_conf;
 uint16_t checksum = 0;

[Qemu-devel] [PATCH v3 2/3] tests: e1000: test additional device IDs

2014-05-31 Thread Gabriel L. Somlo
Update e1000-test.c to check all currently supported devices.

Suggested-by: Andreas Färber 
Signed-off-by: Gabriel Somlo 
Reviewed-by: Michael S. Tsirkin 
---
 tests/e1000-test.c | 34 +++---
 1 file changed, 27 insertions(+), 7 deletions(-)

diff --git a/tests/e1000-test.c b/tests/e1000-test.c
index a8ba2fc..53c41f8 100644
--- a/tests/e1000-test.c
+++ b/tests/e1000-test.c
@@ -13,21 +13,41 @@
 #include "qemu/osdep.h"
 
 /* Tests only initialization so far. TODO: Replace with functional tests */
-static void nop(void)
+static void test_device(gconstpointer data)
 {
+const char *model = data;
+QTestState *s;
+char *args;
+
+args = g_strdup_printf("-device %s", model);
+s = qtest_start(args);
+
+if (s) {
+qtest_quit(s);
+}
+g_free(args);
 }
 
+static const char *models[] = {
+"e1000",
+"e1000-82540em",
+"e1000-82544gc",
+"e1000-82545em",
+"e1000-82573l",
+};
+
 int main(int argc, char **argv)
 {
-int ret;
+int i;
 
 g_test_init(&argc, &argv, NULL);
-qtest_add_func("/e1000/nop", nop);
 
-qtest_start("-device e1000");
-ret = g_test_run();
+for (i = 0; i < ARRAY_SIZE(models); i++) {
+char *path;
 
-qtest_end();
+path = g_strdup_printf("/%s/e1000/%s", qtest_get_arch(), models[i]);
+g_test_add_data_func(path, models[i], test_device);
+}
 
-return ret;
+return g_test_run();
 }
-- 
1.9.3




[Qemu-devel] When should management tools use q35?

2014-05-31 Thread Cole Robinson
Hi all,

There was a bit of discussion recently about exposing q35 in virt-manager:

http://www.redhat.com/archives/virt-tools-list/2014-May/msg1.html

In that thread, Gerd suggested a 'rule of thumb' to use q35 for any guest OS
released in 2010 or later. Sounds reasonable to me, but I'm curious if anyone
else wants to weigh in.

Is q35 in 'good enough' shape to turn on a default like that? Does it still
block migration? (pretty sure that was fixed, but I haven't confirmed)

If it is in good enough shape, is there a minimum recommended qemu version?

Thanks,
Cole



Re: [Qemu-devel] [PULL 21/23] bsd-user: replace fprintf(stderr, ...) with error_report()

2014-05-31 Thread Peter Maydell
On 26 May 2014 08:20, Michael Tokarev  wrote:
> From: Le Tan 
>
> Replace fprintf(stderr,...) with error_report() in files bsd-user/*.
> The trailing "\n"s of the @fmt argument have been removed
> because @fmt of error_report() should not contain newline.
>
> Signed-off-by: Le Tan 
> Signed-off-by: Michael Tokarev 

Was this patch tested? Building on FreeBSD the compiler
complains:
"warning: implicit declaration of function 'error_report' is invalid in C99"

because none of these bsd-user files include a header which
gives a prototype for error_report. Also, these are just
straightforward reporting of command line errors, and I
think that, like the linux-user code, we should handle
these in the obvious way by printing to stderr. There's no
need to drag in the error-handling framework for this,
especially since user-mode doesn't have the "maybe we
need to send this to the monitor" issues system emulation
does.

In short, I think we need to revert this commit
(1fba509527beb).

thanks
-- PMM



[Qemu-devel] [PATCH 2/3] nbd: Add exports listing support.

2014-05-31 Thread Hani Benhabiles
This is added by handling the NBD_OPT_LIST and NBD_OPT_ABORT options.

NBD_REP_ERR_UNSUP is also sent for unknown NBD option values.

Signed-off-by: Hani Benhabiles 
---
 include/block/nbd.h |   5 ++
 nbd.c   | 197 +---
 2 files changed, 162 insertions(+), 40 deletions(-)

diff --git a/include/block/nbd.h b/include/block/nbd.h
index 95d52ab..fd7e057 100644
--- a/include/block/nbd.h
+++ b/include/block/nbd.h
@@ -51,6 +51,11 @@ struct nbd_reply {
 /* New-style client flags. */
 #define NBD_FLAG_C_FIXED_NEWSTYLE   (1 << 0)/* Fixed newstyle protocol. */
 
+/* Reply types. */
+#define NBD_REP_ACK (1) /* Data sending finished. */
+#define NBD_REP_SERVER  (2) /* Export description. */
+#define NBD_REP_ERR_UNSUP   ((1 << 31) | 1) /* Unknown option. */
+
 #define NBD_CMD_MASK_COMMAND   0x
 #define NBD_CMD_FLAG_FUA   (1 << 16)
 
diff --git a/nbd.c b/nbd.c
index aa2e552..012e5da 100644
--- a/nbd.c
+++ b/nbd.c
@@ -64,6 +64,7 @@
 #define NBD_REPLY_MAGIC 0x67446698
 #define NBD_OPTS_MAGIC  0x49484156454F5054LL
 #define NBD_CLIENT_MAGIC0x420281861253LL
+#define NBD_REP_MAGIC   0x3e889045565a9LL
 
 #define NBD_SET_SOCK_IO(0xab, 0)
 #define NBD_SET_BLKSIZE _IO(0xab, 1)
@@ -77,7 +78,9 @@
 #define NBD_SET_TIMEOUT _IO(0xab, 9)
 #define NBD_SET_FLAGS   _IO(0xab, 10)
 
-#define NBD_OPT_EXPORT_NAME (1 << 0)
+#define NBD_OPT_EXPORT_NAME (1)
+#define NBD_OPT_ABORT   (2)
+#define NBD_OPT_LIST(3)
 
 /* Definitions for opaque data types */
 
@@ -215,54 +218,98 @@ static ssize_t write_sync(int fd, void *buffer, size_t 
size)
 
 */
 
-static int nbd_receive_options(NBDClient *client)
+static int nbd_send_rep(int csock, uint32_t type, uint32_t opt)
 {
-int csock = client->sock;
-char name[256];
-uint32_t tmp, length;
 uint64_t magic;
-int rc;
-
-/* Client sends:
-[ 0 ..   3]   client flags
-[ 4 ..  11]   NBD_OPTS_MAGIC
-[12 ..  15]   NBD_OPT_EXPORT_NAME
-[16 ..  19]   length
-[20 ..  xx]   export name (length bytes)
- */
+uint32_t len;
 
-rc = -EINVAL;
-if (read_sync(csock, &tmp, sizeof(tmp)) != sizeof(tmp)) {
-LOG("read failed");
-goto fail;
+magic = cpu_to_be64(NBD_REP_MAGIC);
+if (write_sync(csock, &magic, sizeof(magic)) != sizeof(magic)) {
+LOG("write failed (rep magic)");
+return -EINVAL;
 }
-TRACE("Checking client flags");
-tmp = be32_to_cpu(tmp);
-if (tmp != 0 && tmp != NBD_FLAG_C_FIXED_NEWSTYLE) {
-LOG("Bad client flags received");
-goto fail;
+opt = cpu_to_be32(opt);
+if (write_sync(csock, &opt, sizeof(opt)) != sizeof(opt)) {
+LOG("write failed (rep opt)");
+return -EINVAL;
 }
-
-if (read_sync(csock, &magic, sizeof(magic)) != sizeof(magic)) {
-LOG("read failed");
-goto fail;
+type = cpu_to_be32(type);
+if (write_sync(csock, &type, sizeof(type)) != sizeof(type)) {
+LOG("write failed (rep type)");
+return -EINVAL;
 }
-TRACE("Checking opts magic");
-if (magic != be64_to_cpu(NBD_OPTS_MAGIC)) {
-LOG("Bad magic received");
-goto fail;
+len = cpu_to_be32(0);
+if (write_sync(csock, &len, sizeof(len)) != sizeof(len)) {
+LOG("write failed (rep data length)");
+return -EINVAL;
 }
+return 0;
+}
 
-if (read_sync(csock, &tmp, sizeof(tmp)) != sizeof(tmp)) {
-LOG("read failed");
-goto fail;
+static int nbd_send_rep_list(int csock, NBDExport *exp)
+{
+uint64_t magic, name_len;
+uint32_t opt, type, len;
+
+name_len = strlen(exp->name);
+magic = cpu_to_be64(NBD_REP_MAGIC);
+if (write_sync(csock, &magic, sizeof(magic)) != sizeof(magic)) {
+LOG("write failed (magic)");
+return -EINVAL;
 }
-TRACE("Checking option");
-if (tmp != be32_to_cpu(NBD_OPT_EXPORT_NAME)) {
-LOG("Bad option received");
-goto fail;
+opt = cpu_to_be32(NBD_OPT_LIST);
+if (write_sync(csock, &opt, sizeof(opt)) != sizeof(opt)) {
+LOG("write failed (opt)");
+return -EINVAL;
+}
+type = cpu_to_be32(NBD_REP_SERVER);
+if (write_sync(csock, &type, sizeof(type)) != sizeof(type)) {
+LOG("write failed (reply type)");
+return -EINVAL;
+}
+len = cpu_to_be32(name_len + sizeof(len));
+if (write_sync(csock, &len, sizeof(len)) != sizeof(len)) {
+LOG("write failed (length)");
+return -EINVAL;
+}
+len = cpu_to_be32(name_len);
+if (write_sync(csock, &len, sizeof(len)) != sizeof(len)) {
+LOG("write failed (length)");
+return -EINVAL;
+}
+if (write_sync(csock, exp->name, name_len) != name_len) {
+LOG("write failed (buffer)");
+return -EINVAL;
+}
+return 0;
+}
+
+static int nbd_send_li

[Qemu-devel] [PATCH 3/3] nbd: Shutdown socket before closing.

2014-05-31 Thread Hani Benhabiles
This forces finishing data sending to client before closing the socket like in
exports listing or replying with NBD_REP_ERR_UNSUP cases.

Signed-off-by: Hani Benhabiles 
---
 blockdev-nbd.c | 1 +
 qemu-nbd.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index b60b66d..e609f66 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -28,6 +28,7 @@ static void nbd_accept(void *opaque)
 
 int fd = accept(server_fd, (struct sockaddr *)&addr, &addr_len);
 if (fd >= 0 && !nbd_client_new(NULL, fd, nbd_client_put)) {
+shutdown(fd, SHUT_RDWR);
 close(fd);
 }
 }
diff --git a/qemu-nbd.c b/qemu-nbd.c
index ba60436..bf42861 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -372,6 +372,7 @@ static void nbd_accept(void *opaque)
 if (nbd_client_new(exp, fd, nbd_client_closed)) {
 nb_fds++;
 } else {
+shutdown(fd, SHUT_RDWR);
 close(fd);
 }
 }
-- 
1.8.3.2




[Qemu-devel] [PATCH 0/3] nbd: Add exports listing option

2014-05-31 Thread Hani Benhabiles
Compared to v1:
* 2/3: Handle options in a loop. Handle NBD_OPT_ABORT and send NBD_REP_ERR_UNSUP
   accordingly.
* 3/3: New patch.

Hani Benhabiles (3):
  nbd: Handle fixed new-style clients.
  nbd: Add exports listing support.
  nbd: Shutdown socket before closing.

 blockdev-nbd.c  |   1 +
 include/block/nbd.h |  11 +++
 nbd.c   | 197 +---
 qemu-nbd.c  |   1 +
 4 files changed, 171 insertions(+), 39 deletions(-)

-- 
1.8.3.2




[Qemu-devel] [PATCH 1/3] nbd: Handle fixed new-style clients.

2014-05-31 Thread Hani Benhabiles
Signed-off-by: Hani Benhabiles 
---
 include/block/nbd.h |  6 ++
 nbd.c   | 12 +++-
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/include/block/nbd.h b/include/block/nbd.h
index 79502a0..95d52ab 100644
--- a/include/block/nbd.h
+++ b/include/block/nbd.h
@@ -45,6 +45,12 @@ struct nbd_reply {
 #define NBD_FLAG_ROTATIONAL (1 << 4)/* Use elevator algorithm - 
rotational media */
 #define NBD_FLAG_SEND_TRIM  (1 << 5)/* Send TRIM (discard) */
 
+/* New-style global flags. */
+#define NBD_FLAG_FIXED_NEWSTYLE (1 << 0)/* Fixed newstyle protocol. */
+
+/* New-style client flags. */
+#define NBD_FLAG_C_FIXED_NEWSTYLE   (1 << 0)/* Fixed newstyle protocol. */
+
 #define NBD_CMD_MASK_COMMAND   0x
 #define NBD_CMD_FLAG_FUA   (1 << 16)
 
diff --git a/nbd.c b/nbd.c
index e0d032c..aa2e552 100644
--- a/nbd.c
+++ b/nbd.c
@@ -224,7 +224,7 @@ static int nbd_receive_options(NBDClient *client)
 int rc;
 
 /* Client sends:
-[ 0 ..   3]   reserved (0)
+[ 0 ..   3]   client flags
 [ 4 ..  11]   NBD_OPTS_MAGIC
 [12 ..  15]   NBD_OPT_EXPORT_NAME
 [16 ..  19]   length
@@ -236,9 +236,10 @@ static int nbd_receive_options(NBDClient *client)
 LOG("read failed");
 goto fail;
 }
-TRACE("Checking reserved");
-if (tmp != 0) {
-LOG("Bad reserved received");
+TRACE("Checking client flags");
+tmp = be32_to_cpu(tmp);
+if (tmp != 0 && tmp != NBD_FLAG_C_FIXED_NEWSTYLE) {
+LOG("Bad client flags received");
 goto fail;
 }
 
@@ -246,7 +247,7 @@ static int nbd_receive_options(NBDClient *client)
 LOG("read failed");
 goto fail;
 }
-TRACE("Checking reserved");
+TRACE("Checking opts magic");
 if (magic != be64_to_cpu(NBD_OPTS_MAGIC)) {
 LOG("Bad magic received");
 goto fail;
@@ -333,6 +334,7 @@ static int nbd_send_negotiate(NBDClient *client)
 cpu_to_be16w((uint16_t*)(buf + 26), client->exp->nbdflags | myflags);
 } else {
 cpu_to_be64w((uint64_t*)(buf + 8), NBD_OPTS_MAGIC);
+cpu_to_be16w((uint16_t *)(buf + 16), NBD_FLAG_FIXED_NEWSTYLE);
 }
 
 if (client->exp) {
-- 
1.8.3.2




Re: [Qemu-devel] [RFC 0/5] nbd: Adapt for dataplane

2014-05-31 Thread Max Reitz

On 31.05.2014 20:43, Max Reitz wrote:

[snip]

However, if bs_aio_detach() is called from a different thread than the
old AioContext is running in, we may still have coroutines running for
which we should wait before returning from bs_aio_detach().


After re-reading Stefan's RFC and the AIO locking code, would it suffice 
to call aio_context_acquire() and aio_context_release() on the old 
AioContext at the end of bs_aio_detach() to ensure all coroutines are 
settled? If not, I guess I have to wait until the coroutine variables 
are set to NULL (which indicates they have completely finished 
execution; however, this is not actually necessary and might lead to an 
infinite loop if the block driver keeps yielding due to some condition 
related to the AioContext switch), or I really have to switch the 
existing coroutines to the new AioContext while they are running. Doing 
this from the outside will probably be even messier than it would 
already be from the inside, so I sure hope to be able to avoid this…


Max



[Qemu-devel] [PATCH] qemu-img: Report error even with --oformat=json

2014-05-31 Thread Max Reitz
img_check() should report that the format of the given image does not
support checks even if JSON output is desired. JSON data is output to
stdout, as opposed to error messages, which are (in the case of
qemu-img) printed to stderr. Therefore, it is easy to distinguish
between the two.

Also, img_info() does already use error_report() for human-readable
messages even though JSON output is desired (through
collect_image_info_list()).

Signed-off-by: Max Reitz 
---
As the old code deliberately emitted the error only in case of
human-readable output, I asked Federico, the original author, for his
opinion in https://bugzilla.redhat.com/show_bug.cgi?id=1054753, but did
not receive a reply so far.
---
 qemu-img.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/qemu-img.c b/qemu-img.c
index d118da5..b3d2bc6 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -663,9 +663,7 @@ static int img_check(int argc, char **argv)
 ret = collect_image_check(bs, check, filename, fmt, fix);
 
 if (ret == -ENOTSUP) {
-if (output_format == OFORMAT_HUMAN) {
-error_report("This image format does not support checks");
-}
+error_report("This image format does not support checks");
 ret = 63;
 goto fail;
 }
-- 
1.9.3




Re: [Qemu-devel] [PATCH v5 0/3] Quorum maintaince operations

2014-05-31 Thread Benoît Canet
The Saturday 31 May 2014 à 20:47:47 (+0200), Max Reitz wrote :
> On 31.05.2014 20:45, Benoît Canet wrote:
> >The Friday 30 May 2014 à 19:53:12 (+0200), Max Reitz wrote :
> >>On 30.05.2014 13:18, Benoît Canet wrote:
> >>>These are the last bits required to make quorum usable in production.
> >>>
> >>>v5: rebase on latest Stefan's block branch [Kevin]
> >>>
> >>>v4:
> >>> update patchset to stefan's block branch
> >>> drop Max reviewed by because the series changes
> >>>
> >>>Benoît Canet (3):
> >>>   quorum: Add the rewrite-corrupted parameter to quorum.
> >>>   block: Add drive-mirror-replace command
> >>>   qemu-iotests: Add 096 new test for drive-mirror-replace.
> >>Independently of this series, while looking at patch 1 again
> >>(although I had reviewed it before already), I noticed that
> >>quorum_get_winner() does not select the definite winner, but only a
> >>winner. So if you have a quorum instance with four children and a
> >>threshold of two, it may happen that there are basically two winners
> >>which both fulfill the threshold condition. In this case,
> >>quorum_get_winner() will just return the first winner. However, I
> >>think it should then return that there is no winner (i.e., NULL).
> >>
> >>On the other hand, the user should be aware that it may be a bad
> >>idea to choose a threshold which does not exceed half of the
> >>children count; thus, I'm just asking what you think about this. :-)
> >I think Quorum n/(2 *n) is a bad idea. (n + 1) / (2 *n) is a least required.
> >
> >I wonder where we could put some documentation about this for the user.
> 
> Well, quorum_valid_threshold() exists and could check this… Maybe it
> could at least emit a warning?
> 
> Max

Thanks,

Good idea I will write a patch doing this.

Best regards

Benoît
> 
> >Best regards
> >
> >Benoît
> >
> >>Max
> >>
> 
> 



[Qemu-devel] [RFC 1/5] nbd: Correct name comparison for export_set_name()

2014-05-31 Thread Max Reitz
exp->name == name is certainly true if both strings are equal and will
work for both of them being NULL (which is important to check here);
however, the strings may also be equal without having the same address,
in which case there is no need to replace the export's name either.
Therefore, add a check for this case.

Signed-off-by: Max Reitz 
---
 nbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nbd.c b/nbd.c
index e5084b6..0787cba 100644
--- a/nbd.c
+++ b/nbd.c
@@ -832,7 +832,7 @@ NBDExport *nbd_export_find(const char *name)
 
 void nbd_export_set_name(NBDExport *exp, const char *name)
 {
-if (exp->name == name) {
+if (exp->name == name || (exp->name && name && !strcmp(exp->name, name))) {
 return;
 }
 
-- 
1.9.3




Re: [Qemu-devel] [PATCH v5 0/3] Quorum maintaince operations

2014-05-31 Thread Max Reitz

On 31.05.2014 20:45, Benoît Canet wrote:

The Friday 30 May 2014 à 19:53:12 (+0200), Max Reitz wrote :

On 30.05.2014 13:18, Benoît Canet wrote:

These are the last bits required to make quorum usable in production.

v5: rebase on latest Stefan's block branch [Kevin]

v4:
 update patchset to stefan's block branch
 drop Max reviewed by because the series changes

Benoît Canet (3):
   quorum: Add the rewrite-corrupted parameter to quorum.
   block: Add drive-mirror-replace command
   qemu-iotests: Add 096 new test for drive-mirror-replace.

Independently of this series, while looking at patch 1 again
(although I had reviewed it before already), I noticed that
quorum_get_winner() does not select the definite winner, but only a
winner. So if you have a quorum instance with four children and a
threshold of two, it may happen that there are basically two winners
which both fulfill the threshold condition. In this case,
quorum_get_winner() will just return the first winner. However, I
think it should then return that there is no winner (i.e., NULL).

On the other hand, the user should be aware that it may be a bad
idea to choose a threshold which does not exceed half of the
children count; thus, I'm just asking what you think about this. :-)

I think Quorum n/(2 *n) is a bad idea. (n + 1) / (2 *n) is a least required.

I wonder where we could put some documentation about this for the user.


Well, quorum_valid_threshold() exists and could check this… Maybe it 
could at least emit a warning?


Max


Best regards

Benoît


Max






Re: [Qemu-devel] [PATCH v5 0/3] Quorum maintaince operations

2014-05-31 Thread Benoît Canet
The Friday 30 May 2014 à 19:53:12 (+0200), Max Reitz wrote :
> On 30.05.2014 13:18, Benoît Canet wrote:
> >These are the last bits required to make quorum usable in production.
> >
> >v5: rebase on latest Stefan's block branch [Kevin]
> >
> >v4:
> > update patchset to stefan's block branch
> > drop Max reviewed by because the series changes
> >
> >Benoît Canet (3):
> >   quorum: Add the rewrite-corrupted parameter to quorum.
> >   block: Add drive-mirror-replace command
> >   qemu-iotests: Add 096 new test for drive-mirror-replace.
> 
> Independently of this series, while looking at patch 1 again
> (although I had reviewed it before already), I noticed that
> quorum_get_winner() does not select the definite winner, but only a
> winner. So if you have a quorum instance with four children and a
> threshold of two, it may happen that there are basically two winners
> which both fulfill the threshold condition. In this case,
> quorum_get_winner() will just return the first winner. However, I
> think it should then return that there is no winner (i.e., NULL).
> 
> On the other hand, the user should be aware that it may be a bad
> idea to choose a threshold which does not exceed half of the
> children count; thus, I'm just asking what you think about this. :-)

I think Quorum n/(2 *n) is a bad idea. (n + 1) / (2 *n) is a least required.

I wonder where we could put some documentation about this for the user.

Best regards

Benoît

> 
> Max
> 



[Qemu-devel] [RFC 4/5] block: Add AIO followers

2014-05-31 Thread Max Reitz
If a long-running operation on a BDS wants to always remain in the same
AIO context, it somehow needs to keep track of the BDS changing its
context. This adds a function for registering callbacks on a BDS which
are called whenever the BDS is attached or detached from an AIO context.

Signed-off-by: Max Reitz 
---
 block.c   | 55 +++
 include/block/block_int.h | 40 ++
 2 files changed, 95 insertions(+)

diff --git a/block.c b/block.c
index fe85d78..9c8dd5b 100644
--- a/block.c
+++ b/block.c
@@ -1775,6 +1775,8 @@ void bdrv_reopen_abort(BDRVReopenState *reopen_state)
 
 void bdrv_close(BlockDriverState *bs)
 {
+BdrvAioFollower *baf, *baf_next;
+
 if (bs->job) {
 block_job_cancel_sync(bs->job);
 }
@@ -1816,6 +1818,11 @@ void bdrv_close(BlockDriverState *bs)
 if (bs->io_limits_enabled) {
 bdrv_io_limits_disable(bs);
 }
+
+QLIST_FOREACH_SAFE(baf, &bs->aio_followers, list, baf_next) {
+g_free(baf);
+}
+QLIST_INIT(&bs->aio_followers);
 }
 
 void bdrv_close_all(void)
@@ -5580,10 +5587,16 @@ AioContext *bdrv_get_aio_context(BlockDriverState *bs)
 
 void bdrv_detach_aio_context(BlockDriverState *bs)
 {
+BdrvAioFollower *baf;
+
 if (!bs->drv) {
 return;
 }
 
+QLIST_FOREACH(baf, &bs->aio_followers, list) {
+baf->aio_context_detached(baf->opaque);
+}
+
 if (bs->drv->bdrv_detach_aio_context) {
 bs->drv->bdrv_detach_aio_context(bs);
 }
@@ -5600,6 +5613,8 @@ void bdrv_detach_aio_context(BlockDriverState *bs)
 void bdrv_attach_aio_context(BlockDriverState *bs,
  AioContext *new_context)
 {
+BdrvAioFollower *baf;
+
 if (!bs->drv) {
 return;
 }
@@ -5615,6 +5630,10 @@ void bdrv_attach_aio_context(BlockDriverState *bs,
 if (bs->drv->bdrv_attach_aio_context) {
 bs->drv->bdrv_attach_aio_context(bs, new_context);
 }
+
+QLIST_FOREACH(baf, &bs->aio_followers, list) {
+baf->aio_context_attached(new_context, baf->opaque);
+}
 }
 
 void bdrv_set_aio_context(BlockDriverState *bs, AioContext *new_context)
@@ -5631,6 +5650,42 @@ void bdrv_set_aio_context(BlockDriverState *bs, 
AioContext *new_context)
 aio_context_release(new_context);
 }
 
+void bdrv_follow_aio(BlockDriverState *bs,
+ void (*aio_context_attached)(AioContext *new_context,
+  void *opaque),
+ void (*aio_context_detached)(void *opaque), void *opaque)
+{
+BdrvAioFollower *baf = g_new(BdrvAioFollower, 1);
+*baf = (BdrvAioFollower){
+.aio_context_attached = aio_context_attached,
+.aio_context_detached = aio_context_detached,
+.opaque   = opaque
+};
+
+QLIST_INSERT_HEAD(&bs->aio_followers, baf, list);
+}
+
+void bdrv_unfollow_aio(BlockDriverState *bs,
+   void (*aio_context_attached)(AioContext *, void *),
+   void (*aio_context_detached)(void *), void *opaque)
+{
+BdrvAioFollower *baf, *baf_next;
+
+QLIST_FOREACH_SAFE(baf, &bs->aio_followers, list, baf_next) {
+if (baf->aio_context_attached == aio_context_attached &&
+baf->aio_context_detached == aio_context_detached &&
+baf->opaque   == opaque)
+{
+QLIST_REMOVE(baf, list);
+g_free(baf);
+
+return;
+}
+}
+
+abort();
+}
+
 void bdrv_add_before_write_notifier(BlockDriverState *bs,
 NotifierWithReturn *notifier)
 {
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 7d156e3..aacc22f 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -283,6 +283,15 @@ typedef struct BlockLimits {
 size_t opt_mem_alignment;
 } BlockLimits;
 
+typedef struct BdrvAioFollower {
+void (*aio_context_attached)(AioContext *new_context, void *opaque);
+void (*aio_context_detached)(void *opaque);
+
+void *opaque;
+
+QLIST_ENTRY(BdrvAioFollower) list;
+} BdrvAioFollower;
+
 /*
  * Note: the function bdrv_append() copies and swaps contents of
  * BlockDriverStates, so if you add new fields to this struct, please
@@ -309,6 +318,10 @@ struct BlockDriverState {
 void *dev_opaque;
 
 AioContext *aio_context; /* event loop used for fd handlers, timers, etc */
+/* long-running tasks intended to always use the same AioContext as this
+ * BDS may register themselves in this list to be notified of changes
+ * regarding this BDS's context */
+QLIST_HEAD(, BdrvAioFollower) aio_followers;
 
 char filename[1024];
 char backing_file[1024]; /* if non zero, the image is a diff of
@@ -425,6 +438,33 @@ void bdrv_detach_aio_context(BlockDriverState *bs);
 void bdrv_attach_aio_context(BlockDriverState *bs,
  AioContext *new_context);
 
+/**
+ * bdrv_follow_

[Qemu-devel] [RFC 5/5] nbd: Follow the BDS' AIO context

2014-05-31 Thread Max Reitz
Keep the NBD server always in the same AIO context as the exported BDS
by calling bdrv_follow_aio() and implementing the required callbacks.

Signed-off-by: Max Reitz 
---
 nbd.c | 36 
 1 file changed, 32 insertions(+), 4 deletions(-)

diff --git a/nbd.c b/nbd.c
index 803b3d7..1898c5e 100644
--- a/nbd.c
+++ b/nbd.c
@@ -808,6 +808,36 @@ static void nbd_request_put(NBDRequest *req)
 nbd_client_put(client);
 }
 
+static int nbd_can_read(void *opaque);
+static void nbd_read(void *opaque);
+static void nbd_restart_write(void *opaque);
+
+static void bs_aio_attach(AioContext *ctx, void *opaque)
+{
+NBDExport *exp = opaque;
+NBDClient *client;
+
+QTAILQ_FOREACH(client, &exp->clients, next) {
+aio_set_fd_handler2(ctx, client->sock,
+nbd_can_read, nbd_read, NULL, client);
+}
+
+exp->ctx = ctx;
+}
+
+static void bs_aio_detach(void *opaque)
+{
+NBDExport *exp = opaque;
+NBDClient *client;
+
+QTAILQ_FOREACH(client, &exp->clients, next) {
+aio_set_fd_handler2(exp->ctx, client->sock,
+NULL, NULL, NULL, NULL);
+}
+
+exp->ctx = NULL;
+}
+
 NBDExport *nbd_export_new(BlockDriverState *bs, off_t dev_offset,
   off_t size, uint32_t nbdflags,
   void (*close)(NBDExport *))
@@ -822,6 +852,7 @@ NBDExport *nbd_export_new(BlockDriverState *bs, off_t 
dev_offset,
 exp->close = close;
 exp->ctx = bdrv_get_aio_context(bs);
 bdrv_ref(bs);
+bdrv_follow_aio(bs, bs_aio_attach, bs_aio_detach, exp);
 return exp;
 }
 
@@ -869,6 +900,7 @@ void nbd_export_close(NBDExport *exp)
 nbd_export_set_name(exp, NULL);
 nbd_export_put(exp);
 if (exp->bs) {
+bdrv_unfollow_aio(exp->bs, bs_aio_attach, bs_aio_detach, exp);
 bdrv_unref(exp->bs);
 exp->bs = NULL;
 }
@@ -912,10 +944,6 @@ void nbd_export_close_all(void)
 }
 }
 
-static int nbd_can_read(void *opaque);
-static void nbd_read(void *opaque);
-static void nbd_restart_write(void *opaque);
-
 static ssize_t nbd_co_send_reply(NBDRequest *req, struct nbd_reply *reply,
  int len)
 {
-- 
1.9.3




[Qemu-devel] [RFC 3/5] nbd: Use aio_set_fd_handler2()

2014-05-31 Thread Max Reitz
Instead of using the main loop function qemu_set_fd_handler2(), use the
AIO function in the context of the exported BDS.

Signed-off-by: Max Reitz 
---
 nbd.c | 21 +++--
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/nbd.c b/nbd.c
index 0787cba..803b3d7 100644
--- a/nbd.c
+++ b/nbd.c
@@ -18,6 +18,7 @@
 
 #include "block/nbd.h"
 #include "block/block.h"
+#include "block/block_int.h"
 
 #include "block/coroutine.h"
 
@@ -100,6 +101,8 @@ struct NBDExport {
 uint32_t nbdflags;
 QTAILQ_HEAD(, NBDClient) clients;
 QTAILQ_ENTRY(NBDExport) next;
+
+AioContext *ctx;
 };
 
 static QTAILQ_HEAD(, NBDExport) exports = QTAILQ_HEAD_INITIALIZER(exports);
@@ -744,7 +747,10 @@ void nbd_client_put(NBDClient *client)
  */
 assert(client->closing);
 
-qemu_set_fd_handler2(client->sock, NULL, NULL, NULL, NULL);
+if (client->exp) {
+aio_set_fd_handler2(client->exp->ctx, client->sock,
+NULL, NULL, NULL, NULL);
+}
 close(client->sock);
 client->sock = -1;
 if (client->exp) {
@@ -797,7 +803,7 @@ static void nbd_request_put(NBDRequest *req)
 g_slice_free(NBDRequest, req);
 
 if (client->nb_requests-- == MAX_NBD_REQUESTS) {
-qemu_notify_event();
+aio_notify(client->exp->ctx);
 }
 nbd_client_put(client);
 }
@@ -814,6 +820,7 @@ NBDExport *nbd_export_new(BlockDriverState *bs, off_t 
dev_offset,
 exp->nbdflags = nbdflags;
 exp->size = size == -1 ? bdrv_getlength(bs) : size;
 exp->close = close;
+exp->ctx = bdrv_get_aio_context(bs);
 bdrv_ref(bs);
 return exp;
 }
@@ -917,8 +924,8 @@ static ssize_t nbd_co_send_reply(NBDRequest *req, struct 
nbd_reply *reply,
 ssize_t rc, ret;
 
 qemu_co_mutex_lock(&client->send_lock);
-qemu_set_fd_handler2(csock, nbd_can_read, nbd_read,
- nbd_restart_write, client);
+aio_set_fd_handler2(client->exp->ctx, csock,
+nbd_can_read, nbd_read, nbd_restart_write, client);
 client->send_coroutine = qemu_coroutine_self();
 
 if (!len) {
@@ -936,7 +943,8 @@ static ssize_t nbd_co_send_reply(NBDRequest *req, struct 
nbd_reply *reply,
 }
 
 client->send_coroutine = NULL;
-qemu_set_fd_handler2(csock, nbd_can_read, nbd_read, NULL, client);
+aio_set_fd_handler2(client->exp->ctx, csock,
+nbd_can_read, nbd_read, NULL, client);
 qemu_co_mutex_unlock(&client->send_lock);
 return rc;
 }
@@ -1179,7 +1187,8 @@ NBDClient *nbd_client_new(NBDExport *exp, int csock,
 }
 client->close = close;
 qemu_co_mutex_init(&client->send_lock);
-qemu_set_fd_handler2(csock, nbd_can_read, nbd_read, NULL, client);
+aio_set_fd_handler2(client->exp->ctx, csock,
+nbd_can_read, nbd_read, NULL, client);
 
 if (exp) {
 QTAILQ_INSERT_TAIL(&exp->clients, client, next);
-- 
1.9.3




[Qemu-devel] [RFC 0/5] nbd: Adapt for dataplane

2014-05-31 Thread Max Reitz
For the NBD server to work with dataplane, it needs to correctly access
the exported BDS. It makes the most sense to run both in the same
AioContext, therefore this series implements methods for tracking a
BDS's AioContext and makes NBD make use of this for keeping the clients
connected to that BDS in the same AioContext.

The reason this is an RFC and not a PATCH is my inexperience with AIO,
coroutines and the like. Also, I'm not sure about what to do about the
coroutines. The NBD server has up to two coroutines per client: One for
receiving and one for sending. Theoretically, both have to be
"transferred" to the new AioContext if it is changed; however, as far as
I see it, coroutines are not really bound to an AioContext, they are
simply run in the AioContext entering them. Therefore, I think a
transfer is unnecessary. All coroutines are entered from nbd_read() and
nbd_restart_write(), both of which are AIO routines registered via
aio_set_fd_handler2().

As bs_aio_detach() unregisters all of these routines, the coroutines can
no longer be entered, but only after bs_aio_attach() is called again.
Then, when they are called, they will enter the coroutines in the new
AioContext. Therefore, I think an explicit transfer unnecessary.

However, if bs_aio_detach() is called from a different thread than the
old AioContext is running in, we may still have coroutines running for
which we should wait before returning from bs_aio_detach().

But because of my inexperience with coroutines, I'm not sure. I now have
these patches nearly unchanged here for about a week and I'm looking for
ways of testing them, but so far I could only test whether the old use
cases work, but not whether they will work for what they are intended to
do: With BDS changing their AioContext.

So, because I'm not sure what else to do and because I don't know how to
test multiple AIO threads (how do I move a BDS into another iothread?)
I'm just sending this out as an RFC.


Max Reitz (5):
  nbd: Correct name comparison for export_set_name()
  aio: Add io_read_poll() callback
  nbd: Use aio_set_fd_handler2()
  block: Add AIO followers
  nbd: Follow the BDS' AIO context

 aio-posix.c   | 26 -
 block.c   | 55 +++
 include/block/aio.h   | 12 ++
 include/block/block_int.h | 40 
 include/qemu/main-loop.h  |  1 -
 nbd.c | 59 ++-
 6 files changed, 175 insertions(+), 18 deletions(-)

-- 
1.9.3




[Qemu-devel] [RFC 2/5] aio: Add io_read_poll() callback

2014-05-31 Thread Max Reitz
Similar to how qemu_set_fd_handler2() allows defining a function which
checks whether the recipient is ready to read, add aio_set_fd_handler2()
with a parameter for defining such a callback.

Signed-off-by: Max Reitz 
---
 aio-posix.c  | 26 --
 include/block/aio.h  | 12 
 include/qemu/main-loop.h |  1 -
 3 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/aio-posix.c b/aio-posix.c
index f921d4f..267df35 100644
--- a/aio-posix.c
+++ b/aio-posix.c
@@ -21,6 +21,7 @@
 struct AioHandler
 {
 GPollFD pfd;
+IOCanReadHandler *io_read_poll;
 IOHandler *io_read;
 IOHandler *io_write;
 int deleted;
@@ -42,11 +43,12 @@ static AioHandler *find_aio_handler(AioContext *ctx, int fd)
 return NULL;
 }
 
-void aio_set_fd_handler(AioContext *ctx,
-int fd,
-IOHandler *io_read,
-IOHandler *io_write,
-void *opaque)
+void aio_set_fd_handler2(AioContext *ctx,
+ int fd,
+ IOCanReadHandler *io_read_poll,
+ IOHandler *io_read,
+ IOHandler *io_write,
+ void *opaque)
 {
 AioHandler *node;
 
@@ -80,6 +82,7 @@ void aio_set_fd_handler(AioContext *ctx,
 g_source_add_poll(&ctx->source, &node->pfd);
 }
 /* Update handler with latest information */
+node->io_read_poll = io_read_poll;
 node->io_read = io_read;
 node->io_write = io_write;
 node->opaque = opaque;
@@ -92,6 +95,15 @@ void aio_set_fd_handler(AioContext *ctx,
 aio_notify(ctx);
 }
 
+void aio_set_fd_handler(AioContext *ctx,
+int fd,
+IOHandler *io_read,
+IOHandler *io_write,
+void *opaque)
+{
+aio_set_fd_handler2(ctx, fd, NULL, io_read, io_write, opaque);
+}
+
 void aio_set_event_notifier(AioContext *ctx,
 EventNotifier *notifier,
 EventNotifierHandler *io_read)
@@ -108,7 +120,9 @@ bool aio_pending(AioContext *ctx)
 int revents;
 
 revents = node->pfd.revents & node->pfd.events;
-if (revents & (G_IO_IN | G_IO_HUP | G_IO_ERR) && node->io_read) {
+if (revents & (G_IO_IN | G_IO_HUP | G_IO_ERR) && node->io_read &&
+(!node->io_read_poll || node->io_read_poll(node->opaque)))
+{
 return true;
 }
 if (revents & (G_IO_OUT | G_IO_ERR) && node->io_write) {
diff --git a/include/block/aio.h b/include/block/aio.h
index a92511b..0a0ca14 100644
--- a/include/block/aio.h
+++ b/include/block/aio.h
@@ -44,6 +44,7 @@ void qemu_aio_release(void *p);
 typedef struct AioHandler AioHandler;
 typedef void QEMUBHFunc(void *opaque);
 typedef void IOHandler(void *opaque);
+typedef int IOCanReadHandler(void *opaque);
 
 struct AioContext {
 GSource source;
@@ -230,6 +231,17 @@ void aio_set_fd_handler(AioContext *ctx,
 IOHandler *io_read,
 IOHandler *io_write,
 void *opaque);
+
+/* Similar to aio_set_fd_handler(), only that this form additionally allows
+ * registering an IOCanReadHandler which can be used for temporarily inhibiting
+ * io_read() from being called.
+ */
+void aio_set_fd_handler2(AioContext *ctx,
+ int fd,
+ IOCanReadHandler *io_read_poll,
+ IOHandler *io_read,
+ IOHandler *io_write,
+ void *opaque);
 #endif
 
 /* Register an event notifier and associated callbacks.  Behaves very similarly
diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h
index 6f0200a..01273f6 100644
--- a/include/qemu/main-loop.h
+++ b/include/qemu/main-loop.h
@@ -169,7 +169,6 @@ void qemu_del_wait_object(HANDLE handle, WaitObjectFunc 
*func, void *opaque);
 /* async I/O support */
 
 typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
-typedef int IOCanReadHandler(void *opaque);
 
 /**
  * qemu_set_fd_handler2: Register a file descriptor with the main loop
-- 
1.9.3




[Qemu-devel] [PATCH] thread-pool: fix deadlock when callbacks depends on each other

2014-05-31 Thread Marcin Gibuła
When two coroutines submit I/O and first coroutine depends on second to 
complete (by calling bdrv_drain_all), deadlock may occur.


This is because both requests may have completed before thread pool 
notifier got called. Then, when notifier gets executed and first 
coroutine calls aio_pool() to make progress, it will hang forever, as 
notifier's descriptor has been already marked clear.


This patch fixes this, by rearming thread pool notifier if there are 
more than one completed requests on list.


Without this patch, I could reproduce this bug with snapshot-commit with 
about 1 per 10 tries. With this patch, I couldn't reproduce it any more.


Signed-off-by: Marcin Gibula 
---

--- thread-pool.c   2014-04-17 15:44:45.0 +0200
+++ thread-pool.c   2014-05-31 20:20:26.083011514 +0200
@@ -76,6 +76,8 @@ struct ThreadPool {
 int new_threads; /* backlog of threads we need to create */
 int pending_threads; /* threads created but not running yet */
 int pending_cancellations; /* whether we need a cond_broadcast */
+int pending_completions; /* whether we need to rearm notifier when
+executing callback */
 bool stopping;
 };

@@ -110,6 +112,10 @@ static void *worker_thread(void *opaque)
 ret = req->func(req->arg);

 req->ret = ret;
+if (req->common.cb) {
+pool->pending_completions++;
+}
+
 /* Write ret before state.  */
 smp_wmb();
 req->state = THREAD_DONE;
@@ -185,6 +191,14 @@ restart:
 }
 if (elem->state == THREAD_DONE && elem->common.cb) {
 QLIST_REMOVE(elem, all);
+/* If more completed requests are waiting, notifier needs
+ * to be rearmed so callback can progress with aio_pool().
+ */
+pool->pending_completions--;
+if (pool->pending_completions) {
+event_notifier_set(notifier);
+}
+
 /* Read state before ret.  */
 smp_rmb();
 elem->common.cb(elem->common.opaque, elem->ret);



[Qemu-devel] [Bug 1292037] Re: Solaris 10 x86 guest crashes qemu with -icount 1 option

2014-05-31 Thread prajeeth
** Description changed:

  Commit: f53f3d0a00b6df39ce8dfca942608e5b6a9a4f71 on qemu.git
  
  Solaris image: Solaris 10 x86 (32 bit)
  
  command: ./i386-softmmu/qemu-system-i386 -hda  -m 2G -icount
  1 -monitor stdio
  
  Crashes saying:
  qemu: Fatal: Raised interrupt while not in I/O function
  
  Host:
  ubuntu x86_64 3.2.0-56 generic
  intel xeon E5649 @ 2.53GHz
+ 
+ 
+ UPDATE:
+ http://lists.gnu.org/archive/html/qemu-devel/2014-05/msg06365.html
+ 
+ Workaround: Rename the kvmvapic.bin file under the pc-bios directory to
+ something different.

** Description changed:

- Commit: f53f3d0a00b6df39ce8dfca942608e5b6a9a4f71 on qemu.git
- 
  Solaris image: Solaris 10 x86 (32 bit)
  
  command: ./i386-softmmu/qemu-system-i386 -hda  -m 2G -icount
  1 -monitor stdio
  
  Crashes saying:
  qemu: Fatal: Raised interrupt while not in I/O function
  
  Host:
  ubuntu x86_64 3.2.0-56 generic
  intel xeon E5649 @ 2.53GHz
  
  
  UPDATE:
+ Tested on QEMU v2.0.50
+ Also affects OpenIndiana
  http://lists.gnu.org/archive/html/qemu-devel/2014-05/msg06365.html
  
  Workaround: Rename the kvmvapic.bin file under the pc-bios directory to
  something different.

** Description changed:

  Solaris image: Solaris 10 x86 (32 bit)
  
  command: ./i386-softmmu/qemu-system-i386 -hda  -m 2G -icount
  1 -monitor stdio
  
  Crashes saying:
  qemu: Fatal: Raised interrupt while not in I/O function
  
  Host:
  ubuntu x86_64 3.2.0-56 generic
  intel xeon E5649 @ 2.53GHz
  
- 
  UPDATE:
  Tested on QEMU v2.0.50
- Also affects OpenIndiana
+ Also affects OpenIndiana (151a8 - Server Build 32bit)
  http://lists.gnu.org/archive/html/qemu-devel/2014-05/msg06365.html
  
  Workaround: Rename the kvmvapic.bin file under the pc-bios directory to
  something different.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1292037

Title:
  Solaris 10 x86 guest crashes qemu with -icount 1 option

Status in QEMU:
  New

Bug description:
  Solaris image: Solaris 10 x86 (32 bit)

  command: ./i386-softmmu/qemu-system-i386 -hda  -m 2G
  -icount 1 -monitor stdio

  Crashes saying:
  qemu: Fatal: Raised interrupt while not in I/O function

  Host:
  ubuntu x86_64 3.2.0-56 generic
  intel xeon E5649 @ 2.53GHz

  UPDATE:
  Tested on QEMU v2.0.50
  Also affects OpenIndiana (151a8 - Server Build 32bit)
  http://lists.gnu.org/archive/html/qemu-devel/2014-05/msg06365.html

  Workaround: Rename the kvmvapic.bin file under the pc-bios directory
  to something different.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1292037/+subscriptions



Re: [Qemu-devel] [PATCH 0/3] input: add support for kbd delays

2014-05-31 Thread Dave Mielke
[quoted lines by Gerd Hoffmann on 2014/05/28 at 14:26 +0200]

Hi:

>Little series of three input patches.  First patch adds support for
>submitting keyboard delays, which will make the input layer setup a
>timer, buffer the following keyboard events, send them to the guest
>once the delay is over.  Second patch makes the send_key monitor command
>use the new service instead of using its own timer.  Third patch inserts
>a delay between keydown and keyup events in the curses ui.
>
>please review & test,

This approach doesn't work, although the problem is different. Input is now 
recognized, but unwanted key repeats creep in. For example, I typed "exit" and 
got "exiitt". I tested this several times while typing as accurately and 
quickly as I could.

My theory is that the key releases aren't being detected by the application 
until the next key press/release delay, thus effectively leaving the keys 
pressed.

I've attached the latest verson of my patch (qemu-kbddelay-2.patch) to this 
message in case you're interested in considering it. It merges the delay option 
into the -k option, so we'd have this:

   -k [[language=]language][,delay=msecs]

-- 
Dave Mielke   | 2213 Fox Crescent | The Bible is the very Word of God.
Phone: 1-613-726-0014 | Ottawa, Ontario   | http://Mielke.cc/bible/
EMail: d...@mielke.cc | Canada  K2A 1H7   | http://FamilyRadio.com/
diff --git a/include/ui/input.h b/include/ui/input.h
index 3d3d487..17c77c8 100644
--- a/include/ui/input.h
+++ b/include/ui/input.h
@@ -35,6 +35,7 @@ void qemu_input_event_sync(void);
 InputEvent *qemu_input_event_new_key(KeyValue *key, bool down);
 void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down);
 void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down);
+void qemu_input_event_set_keyboard_delay(uint64_t duration);
 void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool down);
 int qemu_input_key_value_to_number(const KeyValue *value);
 int qemu_input_key_value_to_qcode(const KeyValue *value);
diff --git a/qemu-options.hx b/qemu-options.hx
index c2c0823..e906f82 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -241,16 +241,20 @@ Preallocate memory when using -mem-path.
 ETEXI
 
 DEF("k", HAS_ARG, QEMU_OPTION_k,
-"-k language use keyboard layout (for example 'fr' for French)\n",
+"-k [[language=]language][,delay=msecs]\n"
+"set keyboard options\n"
+"language: use keyboard layout (for example 'fr' for 
French)\n"
+"delay: ensure minimum delay between keyboard events\n",
 QEMU_ARCH_ALL)
 STEXI
-@item -k @var{language}
+@item -k [[language=]@var{language}][,delay=@var{msecs}]
 @findex -k
-Use keyboard layout @var{language} (for example @code{fr} for
-French). This option is only needed where it is not easy to get raw PC
-keycodes (e.g. on Macs, with some X11 servers or with a VNC
-display). You don't normally need to use it on PC/Linux or PC/Windows
-hosts.
+
+The @option{language} option specifies the keyboard layout
+(for example @code{fr} for French). This option is only needed
+where it is not easy to get raw PC keycodes
+(e.g. on Macs, with some X11 servers, or with a VNC display).
+You don't normally need to use it on PC/Linux or PC/Windows hosts.
 
 The available layouts are:
 @example
@@ -260,6 +264,18 @@ de  en-us  fi  fr-be  hr it  lv  nl-be  pt  sl tr
 @end example
 
 The default is @code{en-us}.
+
+The @option{delay} option sets the minimum delay
+between keyboard events to @var{msecs} milliseconds.
+The default is 0 (no minimum delay).
+This option exists in order to deal with problematic applications
+which run into trouble when keys are typed too quickly.
+Certain UIs, like curses, aggravate the problem
+because they must turn a single user keyboard action
+into several keyboard events being delivered to the virtual machine.
+Only try this option if you encounter an unexpected keyboard input issue,
+for example the input not being recognized at all.
+A duration of 20 seems to be reasonable.
 ETEXI
 
 
diff --git a/ui/input.c b/ui/input.c
index fc91fba..eb6c1dd 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -188,7 +188,9 @@ InputEvent *qemu_input_event_new_key(KeyValue *key, bool 
down)
 return evt;
 }
 
-void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down)
+static void qemu_input_event_send_key_immediate(QemuConsole *src,
+KeyValue *key,
+bool down)
 {
 InputEvent *evt;
 evt = qemu_input_event_new_key(key, down);
@@ -197,6 +199,82 @@ void qemu_input_event_send_key(QemuConsole *src, KeyValue 
*key, bool down)
 qapi_free_InputEvent(evt);
 }
 
+struct PendingKeyEvent {
+struct PendingKeyEvent *next;
+QemuConsole *src;
+KeyValue *key;
+bool down;
+};
+
+static struct PendingKeyEvent *firstPendingKeyEvent = NULL;
+static struct PendingKeyEvent *lastP

[Qemu-devel] [PATCH v1 23/72] qapi: Extract MirrorSyncMode definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 17 -
 qapi/block-core.json | 17 +
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 9fe1cbc..a3321bc 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1002,23 +1002,6 @@
 { 'command': 'query-pci', 'returns': ['PciInfo'] }
 
 ##
-# @MirrorSyncMode:
-#
-# An enumeration of possible behaviors for the initial synchronization
-# phase of storage mirroring.
-#
-# @top: copies data in the topmost image to the destination
-#
-# @full: copies data from all images to the destination
-#
-# @none: only copy data written from now on
-#
-# Since: 1.3
-##
-{ 'enum': 'MirrorSyncMode',
-  'data': ['top', 'full', 'none'] }
-
-##
 # @BlockJobType:
 #
 # Type of a block job.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 0f141d7..cb9ab52 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -447,3 +447,20 @@
 { 'enum': 'BlockdevOnError',
   'data': ['report', 'ignore', 'enospc', 'stop'] }
 
+##
+# @MirrorSyncMode:
+#
+# An enumeration of possible behaviors for the initial synchronization
+# phase of storage mirroring.
+#
+# @top: copies data in the topmost image to the destination
+#
+# @full: copies data from all images to the destination
+#
+# @none: only copy data written from now on
+#
+# Since: 1.3
+##
+{ 'enum': 'MirrorSyncMode',
+  'data': ['top', 'full', 'none'] }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 21/72] qapi: Extract query-blockstats definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 11 ---
 qapi/block-core.json | 11 +++
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 5d22e55..25c594a 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -664,17 +664,6 @@
 { 'command': 'query-iothreads', 'returns': ['IOThreadInfo'] }
 
 ##
-# @query-blockstats:
-#
-# Query the @BlockStats for all virtual block devices.
-#
-# Returns: A list of @BlockStats for each virtual block devices.
-#
-# Since: 0.14.0
-##
-{ 'command': 'query-blockstats', 'returns': ['BlockStats'] }
-
-##
 # @VncClientInfo:
 #
 # Information about a connected VNC client.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index fddcb5f..282154b 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -413,3 +413,14 @@
'*parent': 'BlockStats',
'*backing': 'BlockStats'} }
 
+##
+# @query-blockstats:
+#
+# Query the @BlockStats for all virtual block devices.
+#
+# Returns: A list of @BlockStats for each virtual block devices.
+#
+# Since: 0.14.0
+##
+{ 'command': 'query-blockstats', 'returns': ['BlockStats'] }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 28/72] qapi: Extract block_resize definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 22 --
 qapi/block-core.json | 22 ++
 2 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 95e30a0..88b12d4 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1201,28 +1201,6 @@
 { 'command': 'balloon', 'data': {'value': 'int'} }
 
 ##
-# @block_resize
-#
-# Resize a block image while a guest is running.
-#
-# Either @device or @node-name must be set but not both.
-#
-# @device: #optional the name of the device to get the image resized
-#
-# @node-name: #optional graph node name to get the image resized (Since 2.0)
-#
-# @size:  new image size in bytes
-#
-# Returns: nothing on success
-#  If @device is not a valid block device, DeviceNotFound
-#
-# Since: 0.14.0
-##
-{ 'command': 'block_resize', 'data': { '*device': 'str',
-   '*node-name': 'str',
-   'size': 'int' }}
-
-##
 # @NewImageMode
 #
 # An enumeration that tells QEMU how to set the backing file path in
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 0add09a..a23c1ef 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -560,3 +560,25 @@
 { 'command': 'block_passwd', 'data': {'*device': 'str',
   '*node-name': 'str', 'password': 'str'} }
 
+##
+# @block_resize
+#
+# Resize a block image while a guest is running.
+#
+# Either @device or @node-name must be set but not both.
+#
+# @device: #optional the name of the device to get the image resized
+#
+# @node-name: #optional graph node name to get the image resized (Since 2.0)
+#
+# @size:  new image size in bytes
+#
+# Returns: nothing on success
+#  If @device is not a valid block device, DeviceNotFound
+#
+# Since: 0.14.0
+##
+{ 'command': 'block_resize', 'data': { '*device': 'str',
+   '*node-name': 'str',
+   'size': 'int' }}
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 44/72] qapi: Extract drive-mirror-replace definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 33 -
 qapi/block-core.json | 33 +
 2 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 2c625aa..5ae556c 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1621,39 +1621,6 @@
   'data': {'device': 'str', 'target': 'str', '*arg': 'str'} }
 
 ##
-# @drive-mirror-replace:
-#
-# Manually trigger completion of an active background drive-mirror operation
-# and replace the target reference with the new mirror.
-# This switches the device to write to the target path only.
-# The ability to complete is signaled with a BLOCK_JOB_READY event.
-#
-# This command completes an active drive-mirror background operation
-# synchronously and replaces the target reference with the mirror.
-# The ordering of this command's return with the BLOCK_JOB_COMPLETED event
-# is not defined.  Note that if an I/O error occurs during the processing of
-# this command: 1) the command itself will fail; 2) the error will be processed
-# according to the rerror/werror arguments that were specified when starting
-# the operation.
-#
-# A cancelled or paused drive-mirror job cannot be completed.
-#
-# @device:   the device name
-# @target-reference: the id or node name of the block driver state to replace
-# @new-node-name:#optional set the node-name of the new block driver state
-#needed if the target reference points to a regular node of
-#the graph
-#
-# Returns: Nothing on success
-#  If no background operation is active on this device, DeviceNotActive
-#
-# Since: 2.1
-##
-{ 'command': 'drive-mirror-replace',
-  'data': { 'device': 'str', 'target-reference': 'str',
-'*new-node-name': 'str' } }
-
-##
 # @ObjectTypeInfo:
 #
 # This structure describes a search result from @qom-list-types
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 55aaf23..1049a05 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1007,3 +1007,36 @@
 ##
 { 'command': 'block-job-complete', 'data': { 'device': 'str' } }
 
+##
+# @drive-mirror-replace:
+#
+# Manually trigger completion of an active background drive-mirror operation
+# and replace the target reference with the new mirror.
+# This switches the device to write to the target path only.
+# The ability to complete is signaled with a BLOCK_JOB_READY event.
+#
+# This command completes an active drive-mirror background operation
+# synchronously and replaces the target reference with the mirror.
+# The ordering of this command's return with the BLOCK_JOB_COMPLETED event
+# is not defined.  Note that if an I/O error occurs during the processing of
+# this command: 1) the command itself will fail; 2) the error will be processed
+# according to the rerror/werror arguments that were specified when starting
+# the operation.
+#
+# A cancelled or paused drive-mirror job cannot be completed.
+#
+# @device:   the device name
+# @target-reference: the id or node name of the block driver state to replace
+# @new-node-name:#optional set the node-name of the new block driver state
+#needed if the target reference points to a regular node of
+#the graph
+#
+# Returns: Nothing on success
+#  If no background operation is active on this device, DeviceNotActive
+#
+# Since: 2.1
+##
+{ 'command': 'drive-mirror-replace',
+  'data': { 'device': 'str', 'target-reference': 'str',
+'*new-node-name': 'str' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 31/72] qapi: Extract DriveBackup definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 42 --
 qapi/block-core.json | 42 ++
 2 files changed, 42 insertions(+), 42 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 6cd9fde..a03125f 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1217,48 +1217,6 @@
   'data': { 'device': 'str', 'name': 'str' } }
 
 ##
-# @DriveBackup
-#
-# @device: the name of the device which should be copied.
-#
-# @target: the target of the new image. If the file exists, or if it
-#  is a device, the existing file/device will be used as the new
-#  destination.  If it does not exist, a new file will be created.
-#
-# @format: #optional the format of the new destination, default is to
-#  probe if @mode is 'existing', else the format of the source
-#
-# @sync: what parts of the disk image should be copied to the destination
-#(all the disk, only the sectors allocated in the topmost image, or
-#only new I/O).
-#
-# @mode: #optional whether and how QEMU should create a new image, default is
-#'absolute-paths'.
-#
-# @speed: #optional the maximum speed, in bytes per second
-#
-# @on-source-error: #optional the action to take on an error on the source,
-#   default 'report'.  'stop' and 'enospc' can only be used
-#   if the block device supports io-status (see BlockInfo).
-#
-# @on-target-error: #optional the action to take on an error on the target,
-#   default 'report' (no limitations, since this applies to
-#   a different block device than @device).
-#
-# Note that @on-source-error and @on-target-error only affect background I/O.
-# If an error occurs during a guest write request, the device's rerror/werror
-# actions will be used.
-#
-# Since: 1.6
-##
-{ 'type': 'DriveBackup',
-  'data': { 'device': 'str', 'target': 'str', '*format': 'str',
-'sync': 'MirrorSyncMode', '*mode': 'NewImageMode',
-'*speed': 'int',
-'*on-source-error': 'BlockdevOnError',
-'*on-target-error': 'BlockdevOnError' } }
-
-##
 # @Abort
 #
 # This action can be used to test transaction failure.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index bf546f7..992fa7b 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -622,3 +622,45 @@
 'snapshot-file': 'str', '*snapshot-node-name': 'str',
 '*format': 'str', '*mode': 'NewImageMode' } }
 
+##
+# @DriveBackup
+#
+# @device: the name of the device which should be copied.
+#
+# @target: the target of the new image. If the file exists, or if it
+#  is a device, the existing file/device will be used as the new
+#  destination.  If it does not exist, a new file will be created.
+#
+# @format: #optional the format of the new destination, default is to
+#  probe if @mode is 'existing', else the format of the source
+#
+# @sync: what parts of the disk image should be copied to the destination
+#(all the disk, only the sectors allocated in the topmost image, or
+#only new I/O).
+#
+# @mode: #optional whether and how QEMU should create a new image, default is
+#'absolute-paths'.
+#
+# @speed: #optional the maximum speed, in bytes per second
+#
+# @on-source-error: #optional the action to take on an error on the source,
+#   default 'report'.  'stop' and 'enospc' can only be used
+#   if the block device supports io-status (see BlockInfo).
+#
+# @on-target-error: #optional the action to take on an error on the target,
+#   default 'report' (no limitations, since this applies to
+#   a different block device than @device).
+#
+# Note that @on-source-error and @on-target-error only affect background I/O.
+# If an error occurs during a guest write request, the device's rerror/werror
+# actions will be used.
+#
+# Since: 1.6
+##
+{ 'type': 'DriveBackup',
+  'data': { 'device': 'str', 'target': 'str', '*format': 'str',
+'sync': 'MirrorSyncMode', '*mode': 'NewImageMode',
+'*speed': 'int',
+'*on-source-error': 'BlockdevOnError',
+'*on-target-error': 'BlockdevOnError' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 17/72] qapi: Extract BlockInfo definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 36 
 qapi/block-core.json | 36 
 2 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 1cb7d2c..ec1bb00 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -664,42 +664,6 @@
 { 'command': 'query-iothreads', 'returns': ['IOThreadInfo'] }
 
 ##
-# @BlockInfo:
-#
-# Block device information.  This structure describes a virtual device and
-# the backing device associated with it.
-#
-# @device: The device name associated with the virtual device.
-#
-# @type: This field is returned only for compatibility reasons, it should
-#not be used (always returns 'unknown')
-#
-# @removable: True if the device supports removable media.
-#
-# @locked: True if the guest has locked this device from having its media
-#  removed
-#
-# @tray_open: #optional True if the device has a tray and it is open
-# (only present if removable is true)
-#
-# @dirty-bitmaps: #optional dirty bitmaps information (only present if the
-# driver has one or more dirty bitmaps) (Since 2.0)
-#
-# @io-status: #optional @BlockDeviceIoStatus. Only present if the device
-# supports it and the VM is configured to stop on errors
-#
-# @inserted: #optional @BlockDeviceInfo describing the device if media is
-#present
-#
-# Since:  0.14.0
-##
-{ 'type': 'BlockInfo',
-  'data': {'device': 'str', 'type': 'str', 'removable': 'bool',
-   'locked': 'bool', '*inserted': 'BlockDeviceInfo',
-   '*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus',
-   '*dirty-bitmaps': ['BlockDirtyInfo'] } }
-
-##
 # @query-block:
 #
 # Get a list of BlockInfo for all virtual block devices.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 9f1995d..24d45f1 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -308,3 +308,39 @@
 { 'type': 'BlockDirtyInfo',
   'data': {'count': 'int', 'granularity': 'int'} }
 
+##
+# @BlockInfo:
+#
+# Block device information.  This structure describes a virtual device and
+# the backing device associated with it.
+#
+# @device: The device name associated with the virtual device.
+#
+# @type: This field is returned only for compatibility reasons, it should
+#not be used (always returns 'unknown')
+#
+# @removable: True if the device supports removable media.
+#
+# @locked: True if the guest has locked this device from having its media
+#  removed
+#
+# @tray_open: #optional True if the device has a tray and it is open
+# (only present if removable is true)
+#
+# @dirty-bitmaps: #optional dirty bitmaps information (only present if the
+# driver has one or more dirty bitmaps) (Since 2.0)
+#
+# @io-status: #optional @BlockDeviceIoStatus. Only present if the device
+# supports it and the VM is configured to stop on errors
+#
+# @inserted: #optional @BlockDeviceInfo describing the device if media is
+#present
+#
+# Since:  0.14.0
+##
+{ 'type': 'BlockInfo',
+  'data': {'device': 'str', 'type': 'str', 'removable': 'bool',
+   'locked': 'bool', '*inserted': 'BlockDeviceInfo',
+   '*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus',
+   '*dirty-bitmaps': ['BlockDirtyInfo'] } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 35/72] qapi: Extract query-named-block-nodes definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 11 ---
 qapi/block-core.json | 11 +++
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 79595b1..a671db7 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1338,17 +1338,6 @@
   'returns': 'str' }
 
 ##
-# @query-named-block-nodes
-#
-# Get the named block driver list
-#
-# Returns: the list of BlockDeviceInfo
-#
-# Since 2.0
-##
-{ 'command': 'query-named-block-nodes', 'returns': [ 'BlockDeviceInfo' ] }
-
-##
 # @drive-mirror
 #
 # Start mirroring a block device's writes to a new destination.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 7c4be1b..319b741 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -740,3 +740,14 @@
 ##
 { 'command': 'drive-backup', 'data': 'DriveBackup' }
 
+##
+# @query-named-block-nodes
+#
+# Get the named block driver list
+#
+# Returns: the list of BlockDeviceInfo
+#
+# Since 2.0
+##
+{ 'command': 'query-named-block-nodes', 'returns': [ 'BlockDeviceInfo' ] }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 43/72] qapi: Extract block-job-complete definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 26 --
 qapi/block-core.json | 26 ++
 2 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 3d4254c..2c625aa 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1621,32 +1621,6 @@
   'data': {'device': 'str', 'target': 'str', '*arg': 'str'} }
 
 ##
-# @block-job-complete:
-#
-# Manually trigger completion of an active background block operation.  This
-# is supported for drive mirroring, where it also switches the device to
-# write to the target path only.  The ability to complete is signaled with
-# a BLOCK_JOB_READY event.
-#
-# This command completes an active background block operation synchronously.
-# The ordering of this command's return with the BLOCK_JOB_COMPLETED event
-# is not defined.  Note that if an I/O error occurs during the processing of
-# this command: 1) the command itself will fail; 2) the error will be processed
-# according to the rerror/werror arguments that were specified when starting
-# the operation.
-#
-# A cancelled or paused job cannot be completed.
-#
-# @device: the device name
-#
-# Returns: Nothing on success
-#  If no background operation is active on this device, DeviceNotActive
-#
-# Since: 1.3
-##
-{ 'command': 'block-job-complete', 'data': { 'device': 'str' } }
-
-##
 # @drive-mirror-replace:
 #
 # Manually trigger completion of an active background drive-mirror operation
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 540b7ee..55aaf23 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -981,3 +981,29 @@
 ##
 { 'command': 'block-job-resume', 'data': { 'device': 'str' } }
 
+##
+# @block-job-complete:
+#
+# Manually trigger completion of an active background block operation.  This
+# is supported for drive mirroring, where it also switches the device to
+# write to the target path only.  The ability to complete is signaled with
+# a BLOCK_JOB_READY event.
+#
+# This command completes an active background block operation synchronously.
+# The ordering of this command's return with the BLOCK_JOB_COMPLETED event
+# is not defined.  Note that if an I/O error occurs during the processing of
+# this command: 1) the command itself will fail; 2) the error will be processed
+# according to the rerror/werror arguments that were specified when starting
+# the operation.
+#
+# A cancelled or paused job cannot be completed.
+#
+# @device: the device name
+#
+# Returns: Nothing on success
+#  If no background operation is active on this device, DeviceNotActive
+#
+# Since: 1.3
+##
+{ 'command': 'block-job-complete', 'data': { 'device': 'str' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 26/72] qapi: Extract query-block-jobs definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 11 ---
 qapi/block-core.json | 11 +++
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index ec08c0e..3aee262 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1002,17 +1002,6 @@
 { 'command': 'query-pci', 'returns': ['PciInfo'] }
 
 ##
-# @query-block-jobs:
-#
-# Return information about long-running block device operations.
-#
-# Returns: a list of @BlockJobInfo for each active block job
-#
-# Since: 1.1
-##
-{ 'command': 'query-block-jobs', 'returns': ['BlockJobInfo'] }
-
-##
 # @quit:
 #
 # This command will cause the QEMU process to exit gracefully.  While every
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 5e2334c..bd0a7c8 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -512,3 +512,14 @@
'offset': 'int', 'busy': 'bool', 'paused': 'bool', 'speed': 'int',
'io-status': 'BlockDeviceIoStatus'} }
 
+##
+# @query-block-jobs:
+#
+# Return information about long-running block device operations.
+#
+# Returns: a list of @BlockJobInfo for each active block job
+#
+# Since: 1.1
+##
+{ 'command': 'query-block-jobs', 'returns': ['BlockJobInfo'] }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 27/72] qapi: Extract block_passwd definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 37 -
 qapi/block-core.json | 37 +
 2 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 3aee262..95e30a0 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1181,43 +1181,6 @@
 { 'command': 'set_link', 'data': {'name': 'str', 'up': 'bool'} }
 
 ##
-# @block_passwd:
-#
-# This command sets the password of a block device that has not been open
-# with a password and requires one.
-#
-# The two cases where this can happen are a block device is created through
-# QEMU's initial command line or a block device is changed through the legacy
-# @change interface.
-#
-# In the event that the block device is created through the initial command
-# line, the VM will start in the stopped state regardless of whether '-S' is
-# used.  The intention is for a management tool to query the block devices to
-# determine which ones are encrypted, set the passwords with this command, and
-# then start the guest with the @cont command.
-#
-# Either @device or @node-name must be set but not both.
-#
-# @device: #optional the name of the block backend device to set the password 
on
-#
-# @node-name: #optional graph node name to set the password on (Since 2.0)
-#
-# @password: the password to use for the device
-#
-# Returns: nothing on success
-#  If @device is not a valid block device, DeviceNotFound
-#  If @device is not encrypted, DeviceNotEncrypted
-#
-# Notes:  Not all block formats support encryption and some that do are not
-# able to validate that a password is correct.  Disk corruption may
-# occur if an invalid password is specified.
-#
-# Since: 0.14.0
-##
-{ 'command': 'block_passwd', 'data': {'*device': 'str',
-  '*node-name': 'str', 'password': 'str'} }
-
-##
 # @balloon:
 #
 # Request the balloon driver to change its balloon size.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index bd0a7c8..0add09a 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -523,3 +523,40 @@
 ##
 { 'command': 'query-block-jobs', 'returns': ['BlockJobInfo'] }
 
+##
+# @block_passwd:
+#
+# This command sets the password of a block device that has not been open
+# with a password and requires one.
+#
+# The two cases where this can happen are a block device is created through
+# QEMU's initial command line or a block device is changed through the legacy
+# @change interface.
+#
+# In the event that the block device is created through the initial command
+# line, the VM will start in the stopped state regardless of whether '-S' is
+# used.  The intention is for a management tool to query the block devices to
+# determine which ones are encrypted, set the passwords with this command, and
+# then start the guest with the @cont command.
+#
+# Either @device or @node-name must be set but not both.
+#
+# @device: #optional the name of the block backend device to set the password 
on
+#
+# @node-name: #optional graph node name to set the password on (Since 2.0)
+#
+# @password: the password to use for the device
+#
+# Returns: nothing on success
+#  If @device is not a valid block device, DeviceNotFound
+#  If @device is not encrypted, DeviceNotEncrypted
+#
+# Notes:  Not all block formats support encryption and some that do are not
+# able to validate that a password is correct.  Disk corruption may
+# occur if an invalid password is specified.
+#
+# Since: 0.14.0
+##
+{ 'command': 'block_passwd', 'data': {'*device': 'str',
+  '*node-name': 'str', 'password': 'str'} }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 24/72] qapi: Extract BlockJobType definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 18 --
 qapi/block-core.json | 18 ++
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index a3321bc..1740ff5 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1002,24 +1002,6 @@
 { 'command': 'query-pci', 'returns': ['PciInfo'] }
 
 ##
-# @BlockJobType:
-#
-# Type of a block job.
-#
-# @commit: block commit job type, see "block-commit"
-#
-# @stream: block stream job type, see "block-stream"
-#
-# @mirror: drive mirror job type, see "drive-mirror"
-#
-# @backup: drive backup job type, see "drive-backup"
-#
-# Since: 1.7
-##
-{ 'enum': 'BlockJobType',
-  'data': ['commit', 'stream', 'mirror', 'backup'] }
-
-##
 # @BlockJobInfo:
 #
 # Information about a long-running block device operation.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index cb9ab52..331b2e6 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -464,3 +464,21 @@
 { 'enum': 'MirrorSyncMode',
   'data': ['top', 'full', 'none'] }
 
+##
+# @BlockJobType:
+#
+# Type of a block job.
+#
+# @commit: block commit job type, see "block-commit"
+#
+# @stream: block stream job type, see "block-stream"
+#
+# @mirror: drive mirror job type, see "drive-mirror"
+#
+# @backup: drive backup job type, see "drive-backup"
+#
+# Since: 1.7
+##
+{ 'enum': 'BlockJobType',
+  'data': ['commit', 'stream', 'mirror', 'backup'] }
+
-- 
1.9.1




[Qemu-devel] Another question regarding hcd-ohci

2014-05-31 Thread BALATON Zoltan

Hello,

I got further with the USB driver for OpenBIOS but there's a part I don't 
understand. When configuring the keyboard it tries to get the HID 
descriptor to find out the keyboard layout from the country code (even 
though it only supports us layout so I can just skip all this for now).


The descriptor is defined in hw/usb/dev-hid.c here:

167 static const USBDescIface desc_iface_keyboard = {
168 .bInterfaceNumber  = 0,
169 .bNumEndpoints = 1,
170 .bInterfaceClass   = USB_CLASS_HID,
171 .bInterfaceSubClass= 0x01, /* boot */
172 .bInterfaceProtocol= 0x01, /* keyboard */
173 .ndesc = 1,
174 .descs = (USBDescOther[]) {
175 {
176 /* HID descriptor */
177 .data = (uint8_t[]) {
178 0x09,  /*  u8  bLength */
179 USB_DT_HID,/*  u8  bDescriptorType */
180 0x11, 0x01,/*  u16 HID_class */
181 0x00,  /*  u8  country_code */
182 0x01,  /*  u8  num_descriptors */
183 USB_DT_REPORT, /*  u8  type: Report */
184 0x3f, 0,   /*  u16 len */
185 },
186 },
187 },

To query the above HID descriptor the driver sends this packet:

ED @ 0x07c9b8c0 fa=1 en=0 d=3 s=0 k=0 f=0 mps=8 h=0 c=0
  head=0x07c9b840 tailp=0x07c9b8a0 next=0x
 TD @ 0x07c9b840 8 of 8 bytes setup r=0 cbp=0x07df75f8 be=0x07df75ff
  data: 81 06 00 21 00 00 08 00

Which is generated with these parameters:

bmRequestType = (device_to_host, standard_type, iface_recp)
bRequest = GET_DESCRIPTOR
wValue = (0x21, 0)

thus I think it sends it as an InterfaceRequest and results in:

status=-3
usb-ohci: got STALL

HALTED!
getting descriptor size (type 21) failed


the code in hw/usb/dev-hid.c:usb_hid_handle_control() only checks for 0x22 
for InterfaceRequests here (by the way there's a #define for this number 
earlier in this file which is not used here):


458 switch (request) {
459 /* hid specific requests */
460 case InterfaceRequest | USB_REQ_GET_DESCRIPTOR:
461 switch (value >> 8) {
--> 462 case 0x22:
463 if (hs->kind == HID_MOUSE) {
464 memcpy(data, qemu_mouse_hid_report_descriptor,
465sizeof(qemu_mouse_hid_report_descriptor));

and only accepts DeviceRequests in hw/usb/desc.c:usb_desc_handle_control() 
that is called before the above:


733 case DeviceRequest | USB_REQ_GET_DESCRIPTOR:
734 ret = usb_desc_get_descriptor(dev, p, value, data, length);
735 break;

What am I missing? Is the driver erroneously sending an incorrect request 
or should the emulation handle this case as well?


Regards,
BALATON Zoltan



[Qemu-devel] [PATCH v1 25/72] qapi: Extract BlockJobInfo definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 30 --
 qapi/block-core.json | 30 ++
 2 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 1740ff5..ec08c0e 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1002,36 +1002,6 @@
 { 'command': 'query-pci', 'returns': ['PciInfo'] }
 
 ##
-# @BlockJobInfo:
-#
-# Information about a long-running block device operation.
-#
-# @type: the job type ('stream' for image streaming)
-#
-# @device: the block device name
-#
-# @len: the maximum progress value
-#
-# @busy: false if the job is known to be in a quiescent state, with
-#no pending I/O.  Since 1.3.
-#
-# @paused: whether the job is paused or, if @busy is true, will
-#  pause itself as soon as possible.  Since 1.3.
-#
-# @offset: the current progress value
-#
-# @speed: the rate limit, bytes per second
-#
-# @io-status: the status of the job (since 1.3)
-#
-# Since: 1.1
-##
-{ 'type': 'BlockJobInfo',
-  'data': {'type': 'str', 'device': 'str', 'len': 'int',
-   'offset': 'int', 'busy': 'bool', 'paused': 'bool', 'speed': 'int',
-   'io-status': 'BlockDeviceIoStatus'} }
-
-##
 # @query-block-jobs:
 #
 # Return information about long-running block device operations.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 331b2e6..5e2334c 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -482,3 +482,33 @@
 { 'enum': 'BlockJobType',
   'data': ['commit', 'stream', 'mirror', 'backup'] }
 
+##
+# @BlockJobInfo:
+#
+# Information about a long-running block device operation.
+#
+# @type: the job type ('stream' for image streaming)
+#
+# @device: the block device name
+#
+# @len: the maximum progress value
+#
+# @busy: false if the job is known to be in a quiescent state, with
+#no pending I/O.  Since 1.3.
+#
+# @paused: whether the job is paused or, if @busy is true, will
+#  pause itself as soon as possible.  Since 1.3.
+#
+# @offset: the current progress value
+#
+# @speed: the rate limit, bytes per second
+#
+# @io-status: the status of the job (since 1.3)
+#
+# Since: 1.1
+##
+{ 'type': 'BlockJobInfo',
+  'data': {'type': 'str', 'device': 'str', 'len': 'int',
+   'offset': 'int', 'busy': 'bool', 'paused': 'bool', 'speed': 'int',
+   'io-status': 'BlockDeviceIoStatus'} }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 72/72] qapi: Extract nbd-server-stop definition into qapi/block.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 10 --
 qapi/block.json  | 10 ++
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 2ad42e4..14b498b 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -2463,16 +2463,6 @@
 { 'command': 'screendump', 'data': {'filename': 'str'} }
 
 ##
-# @nbd-server-stop:
-#
-# Stop QEMU's embedded NBD server, and unregister all devices previously
-# added via @nbd-server-add.
-#
-# Since: 1.3.0
-##
-{ 'command': 'nbd-server-stop' }
-
-##
 # @ChardevFile:
 #
 # Configuration info for file chardevs.
diff --git a/qapi/block.json b/qapi/block.json
index dbe12e1..61c463a 100644
--- a/qapi/block.json
+++ b/qapi/block.json
@@ -154,3 +154,13 @@
 ##
 { 'command': 'nbd-server-add', 'data': {'device': 'str', '*writable': 'bool'} }
 
+##
+# @nbd-server-stop:
+#
+# Stop QEMU's embedded NBD server, and unregister all devices previously
+# added via @nbd-server-add.
+#
+# Since: 1.3.0
+##
+{ 'command': 'nbd-server-stop' }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 71/72] qapi: Extract nbd-server-add definition into qapi/block.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 16 
 qapi/block.json  | 16 
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 614b126..2ad42e4 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -2463,22 +2463,6 @@
 { 'command': 'screendump', 'data': {'filename': 'str'} }
 
 ##
-# @nbd-server-add:
-#
-# Export a device to QEMU's embedded NBD server.
-#
-# @device: Block device to be exported
-#
-# @writable: Whether clients should be able to write to the device via the
-# NBD connection (default false). #optional
-#
-# Returns: error if the device is already marked for export.
-#
-# Since: 1.3.0
-##
-{ 'command': 'nbd-server-add', 'data': {'device': 'str', '*writable': 'bool'} }
-
-##
 # @nbd-server-stop:
 #
 # Stop QEMU's embedded NBD server, and unregister all devices previously
diff --git a/qapi/block.json b/qapi/block.json
index 690c871..dbe12e1 100644
--- a/qapi/block.json
+++ b/qapi/block.json
@@ -138,3 +138,19 @@
 { 'command': 'nbd-server-start',
   'data': { 'addr': 'SocketAddress' } }
 
+##
+# @nbd-server-add:
+#
+# Export a device to QEMU's embedded NBD server.
+#
+# @device: Block device to be exported
+#
+# @writable: Whether clients should be able to write to the device via the
+# NBD connection (default false). #optional
+#
+# Returns: error if the device is already marked for export.
+#
+# Since: 1.3.0
+##
+{ 'command': 'nbd-server-add', 'data': {'device': 'str', '*writable': 'bool'} }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 63/72] qapi: Extract BlockdevRef definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 17 -
 qapi/block-core.json | 17 +
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 53e546b..0e38f83 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3162,23 +3162,6 @@
   'returns': ['RxFilterInfo'] }
 
 ##
-# @BlockdevRef
-#
-# Reference to a block device.
-#
-# @definition:  defines a new block device inline
-# @reference:   references the ID of an existing block device. An
-#   empty string means that no block device should be
-#   referenced.
-#
-# Since: 1.7
-##
-{ 'union': 'BlockdevRef',
-  'discriminator': {},
-  'data': { 'definition': 'BlockdevOptions',
-'reference': 'str' } }
-
-##
 # @blockdev-add:
 #
 # Creates a new block device.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index eb6f12b..b8b4fe1 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1418,3 +1418,20 @@
   'quorum': 'BlockdevOptionsQuorum'
   } }
 
+##
+# @BlockdevRef
+#
+# Reference to a block device.
+#
+# @definition:  defines a new block device inline
+# @reference:   references the ID of an existing block device. An
+#   empty string means that no block device should be
+#   referenced.
+#
+# Since: 1.7
+##
+{ 'union': 'BlockdevRef',
+  'discriminator': {},
+  'data': { 'definition': 'BlockdevOptions',
+'reference': 'str' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 61/72] qapi: Extract BlockdevOptionsQuorum definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 22 --
 qapi/block-core.json | 22 ++
 2 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 2f5e0e2..9e7138e 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3162,28 +3162,6 @@
   'returns': ['RxFilterInfo'] }
 
 ##
-# @BlockdevOptionsQuorum
-#
-# Driver specific block device options for Quorum
-#
-# @blkverify:  #optional true if the driver must print content mismatch
-#  set to false by default
-#
-# @children:   the children block devices to use
-#
-# @vote-threshold: the vote limit under which a read will fail
-#
-# @rewrite-corrupted: #optional rewrite corrupted data when quorum is reached
-# (Since 2.1)
-#
-# Since: 2.0
-##
-{ 'type': 'BlockdevOptionsQuorum',
-  'data': { '*blkverify': 'bool',
-'children': [ 'BlockdevRef' ],
-'vote-threshold': 'int', '*rewrite-corrupted': 'bool' } }
-
-##
 # @BlockdevOptions
 #
 # Options for creating a block device.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index ec563d1..2373ef0 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1350,3 +1350,25 @@
   'data': { 'test': 'BlockdevRef',
 'raw': 'BlockdevRef' } }
 
+##
+# @BlockdevOptionsQuorum
+#
+# Driver specific block device options for Quorum
+#
+# @blkverify:  #optional true if the driver must print content mismatch
+#  set to false by default
+#
+# @children:   the children block devices to use
+#
+# @vote-threshold: the vote limit under which a read will fail
+#
+# @rewrite-corrupted: #optional rewrite corrupted data when quorum is reached
+# (Since 2.1)
+#
+# Since: 2.0
+##
+{ 'type': 'BlockdevOptionsQuorum',
+  'data': { '*blkverify': 'bool',
+'children': [ 'BlockdevRef' ],
+'vote-threshold': 'int', '*rewrite-corrupted': 'bool' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 13/72] qapi: Extract BlockDeviceInfo definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 72 
 qapi/block-core.json | 72 
 2 files changed, 72 insertions(+), 72 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index c6e561c..cdfa222 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -664,78 +664,6 @@
 { 'command': 'query-iothreads', 'returns': ['IOThreadInfo'] }
 
 ##
-# @BlockDeviceInfo:
-#
-# Information about the backing device for a block device.
-#
-# @file: the filename of the backing device
-#
-# @node-name: #optional the name of the block driver node (Since 2.0)
-#
-# @ro: true if the backing device was open read-only
-#
-# @drv: the name of the block format used to open the backing device. As of
-#   0.14.0 this can be: 'blkdebug', 'bochs', 'cloop', 'cow', 'dmg',
-#   'file', 'file', 'ftp', 'ftps', 'host_cdrom', 'host_device',
-#   'host_floppy', 'http', 'https', 'nbd', 'parallels', 'qcow',
-#   'qcow2', 'raw', 'tftp', 'vdi', 'vmdk', 'vpc', 'vvfat'
-#
-# @backing_file: #optional the name of the backing file (for copy-on-write)
-#
-# @backing_file_depth: number of files in the backing file chain (since: 1.2)
-#
-# @encrypted: true if the backing device is encrypted
-#
-# @encryption_key_missing: true if the backing device is encrypted but an
-#  valid encryption key is missing
-#
-# @detect_zeroes: detect and optimize zero writes (Since 2.1)
-#
-# @bps: total throughput limit in bytes per second is specified
-#
-# @bps_rd: read throughput limit in bytes per second is specified
-#
-# @bps_wr: write throughput limit in bytes per second is specified
-#
-# @iops: total I/O operations per second is specified
-#
-# @iops_rd: read I/O operations per second is specified
-#
-# @iops_wr: write I/O operations per second is specified
-#
-# @image: the info of image used (since: 1.6)
-#
-# @bps_max: #optional total max in bytes (Since 1.7)
-#
-# @bps_rd_max: #optional read max in bytes (Since 1.7)
-#
-# @bps_wr_max: #optional write max in bytes (Since 1.7)
-#
-# @iops_max: #optional total I/O operations max (Since 1.7)
-#
-# @iops_rd_max: #optional read I/O operations max (Since 1.7)
-#
-# @iops_wr_max: #optional write I/O operations max (Since 1.7)
-#
-# @iops_size: #optional an I/O size in bytes (Since 1.7)
-#
-# Since: 0.14.0
-#
-##
-{ 'type': 'BlockDeviceInfo',
-  'data': { 'file': 'str', '*node-name': 'str', 'ro': 'bool', 'drv': 'str',
-'*backing_file': 'str', 'backing_file_depth': 'int',
-'encrypted': 'bool', 'encryption_key_missing': 'bool',
-'detect_zeroes': 'BlockdevDetectZeroesOptions',
-'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int',
-'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int',
-'image': 'ImageInfo',
-'*bps_max': 'int', '*bps_rd_max': 'int',
-'*bps_wr_max': 'int', '*iops_max': 'int',
-'*iops_rd_max': 'int', '*iops_wr_max': 'int',
-'*iops_size': 'int' } }
-
-##
 # @BlockDeviceIoStatus:
 #
 # An enumeration of block device I/O status.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 8313403..e129db4 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -178,3 +178,75 @@
'*total-clusters': 'int', '*allocated-clusters': 'int',
'*fragmented-clusters': 'int', '*compressed-clusters': 'int' } }
 
+##
+# @BlockDeviceInfo:
+#
+# Information about the backing device for a block device.
+#
+# @file: the filename of the backing device
+#
+# @node-name: #optional the name of the block driver node (Since 2.0)
+#
+# @ro: true if the backing device was open read-only
+#
+# @drv: the name of the block format used to open the backing device. As of
+#   0.14.0 this can be: 'blkdebug', 'bochs', 'cloop', 'cow', 'dmg',
+#   'file', 'file', 'ftp', 'ftps', 'host_cdrom', 'host_device',
+#   'host_floppy', 'http', 'https', 'nbd', 'parallels', 'qcow',
+#   'qcow2', 'raw', 'tftp', 'vdi', 'vmdk', 'vpc', 'vvfat'
+#
+# @backing_file: #optional the name of the backing file (for copy-on-write)
+#
+# @backing_file_depth: number of files in the backing file chain (since: 1.2)
+#
+# @encrypted: true if the backing device is encrypted
+#
+# @encryption_key_missing: true if the backing device is encrypted but an
+#  valid encryption key is missing
+#
+# @detect_zeroes: detect and optimize zero writes (Since 2.1)
+#
+# @bps: total throughput limit in bytes per second is specified
+#
+# @bps_rd: read throughput limit in bytes per second is specified
+#
+# @bps_wr: write throughput limit in bytes per second is specified
+#
+# @iops: total I/O operations per second is specified
+#
+# @iops_rd: read I/O operations per second is specified
+#
+# @iops_wr: write I/O operations per second is specified
+#
+# @image: the info of image used (since: 1.6)
+#
+# @bps_max: #optional total max in bytes (Since 1.7)
+#

[Qemu-devel] [PATCH v1 59/72] qapi: Extract BlockdevOptionsBlkdebug definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 24 
 qapi/block-core.json | 24 
 2 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index ff85d1c..5f371c8 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3162,30 +3162,6 @@
   'returns': ['RxFilterInfo'] }
 
 ##
-# @BlockdevOptionsBlkdebug
-#
-# Driver specific block device options for blkdebug.
-#
-# @image:   underlying raw block device (or image file)
-#
-# @config:  #optional filename of the configuration file
-#
-# @align:   #optional required alignment for requests in bytes
-#
-# @inject-error:#optional array of error injection descriptions
-#
-# @set-state:   #optional array of state-change descriptions
-#
-# Since: 2.0
-##
-{ 'type': 'BlockdevOptionsBlkdebug',
-  'data': { 'image': 'BlockdevRef',
-'*config': 'str',
-'*align': 'int',
-'*inject-error': ['BlkdebugInjectErrorOptions'],
-'*set-state': ['BlkdebugSetStateOptions'] } }
-
-##
 # @BlockdevOptionsBlkverify
 #
 # Driver specific block device options for blkverify.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 82299b2..cb42a86 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1311,3 +1311,27 @@
 '*state': 'int',
 'new_state': 'int' } }
 
+##
+# @BlockdevOptionsBlkdebug
+#
+# Driver specific block device options for blkdebug.
+#
+# @image:   underlying raw block device (or image file)
+#
+# @config:  #optional filename of the configuration file
+#
+# @align:   #optional required alignment for requests in bytes
+#
+# @inject-error:#optional array of error injection descriptions
+#
+# @set-state:   #optional array of state-change descriptions
+#
+# Since: 2.0
+##
+{ 'type': 'BlockdevOptionsBlkdebug',
+  'data': { 'image': 'BlockdevRef',
+'*config': 'str',
+'*align': 'int',
+'*inject-error': ['BlkdebugInjectErrorOptions'],
+'*set-state': ['BlkdebugSetStateOptions'] } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 60/72] qapi: Extract BlockdevOptionsBlkverify definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 15 ---
 qapi/block-core.json | 15 +++
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 5f371c8..2f5e0e2 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3162,21 +3162,6 @@
   'returns': ['RxFilterInfo'] }
 
 ##
-# @BlockdevOptionsBlkverify
-#
-# Driver specific block device options for blkverify.
-#
-# @test:block device to be tested
-#
-# @raw: raw image used for verification
-#
-# Since: 2.0
-##
-{ 'type': 'BlockdevOptionsBlkverify',
-  'data': { 'test': 'BlockdevRef',
-'raw': 'BlockdevRef' } }
-
-##
 # @BlockdevOptionsQuorum
 #
 # Driver specific block device options for Quorum
diff --git a/qapi/block-core.json b/qapi/block-core.json
index cb42a86..ec563d1 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1335,3 +1335,18 @@
 '*inject-error': ['BlkdebugInjectErrorOptions'],
 '*set-state': ['BlkdebugSetStateOptions'] } }
 
+##
+# @BlockdevOptionsBlkverify
+#
+# Driver specific block device options for blkverify.
+#
+# @test:block device to be tested
+#
+# @raw: raw image used for verification
+#
+# Since: 2.0
+##
+{ 'type': 'BlockdevOptionsBlkverify',
+  'data': { 'test': 'BlockdevRef',
+'raw': 'BlockdevRef' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 69/72] qapi: Extract eject definition into qapi/block.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 19 ---
 qapi/block.json  | 19 +++
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index eebb632..b67c883 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1456,25 +1456,6 @@
 { 'command': 'expire_password', 'data': {'protocol': 'str', 'time': 'str'} }
 
 ##
-# @eject:
-#
-# Ejects a device from a removable drive.
-#
-# @device:  The name of the device
-#
-# @force:   @optional If true, eject regardless of whether the drive is locked.
-#   If not specified, the default value is false.
-#
-# Returns:  Nothing on success
-#   If @device is not a valid block device, DeviceNotFound
-#
-# Notes:Ejecting a device will no media results in success
-#
-# Since: 0.14.0
-##
-{ 'command': 'eject', 'data': {'device': 'str', '*force': 'bool'} }
-
-##
 # @change-vnc-password:
 #
 # Change the VNC server password.
diff --git a/qapi/block.json b/qapi/block.json
index fe4812e..de4b144 100644
--- a/qapi/block.json
+++ b/qapi/block.json
@@ -102,3 +102,22 @@
   'data': { 'device': 'str', '*id': 'str', '*name': 'str'},
   'returns': 'SnapshotInfo' }
 
+##
+# @eject:
+#
+# Ejects a device from a removable drive.
+#
+# @device:  The name of the device
+#
+# @force:   @optional If true, eject regardless of whether the drive is locked.
+#   If not specified, the default value is false.
+#
+# Returns:  Nothing on success
+#   If @device is not a valid block device, DeviceNotFound
+#
+# Notes:Ejecting a device will no media results in success
+#
+# Since: 0.14.0
+##
+{ 'command': 'eject', 'data': {'device': 'str', '*force': 'bool'} }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 55/72] qapi: Extract BlockdevOptionsQcow2 definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 28 
 qapi/block-core.json | 28 
 2 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index ad0f1ae..63a0de3 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3162,34 +3162,6 @@
   'returns': ['RxFilterInfo'] }
 
 ##
-# @BlockdevOptionsQcow2
-#
-# Driver specific block device options for qcow2.
-#
-# @lazy-refcounts:#optional whether to enable the lazy refcounts
-# feature (default is taken from the image file)
-#
-# @pass-discard-request:  #optional whether discard requests to the qcow2
-# device should be forwarded to the data source
-#
-# @pass-discard-snapshot: #optional whether discard requests for the data 
source
-# should be issued when a snapshot operation (e.g.
-# deleting a snapshot) frees clusters in the qcow2 file
-#
-# @pass-discard-other:#optional whether discard requests for the data 
source
-# should be issued on other occasions where a cluster
-# gets freed
-#
-# Since: 1.7
-##
-{ 'type': 'BlockdevOptionsQcow2',
-  'base': 'BlockdevOptionsGenericCOWFormat',
-  'data': { '*lazy-refcounts': 'bool',
-'*pass-discard-request': 'bool',
-'*pass-discard-snapshot': 'bool',
-'*pass-discard-other': 'bool' } }
-
-##
 # @BlkdebugEvent
 #
 # Trigger events supported by blkdebug.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index b762e67..fcb2625 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1212,3 +1212,31 @@
   'base': 'BlockdevOptionsGenericFormat',
   'data': { '*backing': 'BlockdevRef' } }
 
+##
+# @BlockdevOptionsQcow2
+#
+# Driver specific block device options for qcow2.
+#
+# @lazy-refcounts:#optional whether to enable the lazy refcounts
+# feature (default is taken from the image file)
+#
+# @pass-discard-request:  #optional whether discard requests to the qcow2
+# device should be forwarded to the data source
+#
+# @pass-discard-snapshot: #optional whether discard requests for the data 
source
+# should be issued when a snapshot operation (e.g.
+# deleting a snapshot) frees clusters in the qcow2 file
+#
+# @pass-discard-other:#optional whether discard requests for the data 
source
+# should be issued on other occasions where a cluster
+# gets freed
+#
+# Since: 1.7
+##
+{ 'type': 'BlockdevOptionsQcow2',
+  'base': 'BlockdevOptionsGenericCOWFormat',
+  'data': { '*lazy-refcounts': 'bool',
+'*pass-discard-request': 'bool',
+'*pass-discard-snapshot': 'bool',
+'*pass-discard-other': 'bool' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 51/72] qapi: Extract BlockdevOptionsFile definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 13 -
 qapi/block-core.json | 13 +
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 59a7623..9957054 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3162,19 +3162,6 @@
   'returns': ['RxFilterInfo'] }
 
 ##
-# @BlockdevOptionsFile
-#
-# Driver specific block device options for the file backend and similar
-# protocols.
-#
-# @filename:path to the image file
-#
-# Since: 1.7
-##
-{ 'type': 'BlockdevOptionsFile',
-  'data': { 'filename': 'str' } }
-
-##
 # @BlockdevOptionsVVFAT
 #
 # Driver specific block device options for the vvfat protocol.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 2038ef4..262d95c 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1152,3 +1152,16 @@
 '*read-only': 'bool',
 '*detect-zeroes': 'BlockdevDetectZeroesOptions' } }
 
+##
+# @BlockdevOptionsFile
+#
+# Driver specific block device options for the file backend and similar
+# protocols.
+#
+# @filename:path to the image file
+#
+# Since: 1.7
+##
+{ 'type': 'BlockdevOptionsFile',
+  'data': { 'filename': 'str' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 68/72] qapi: Extract blockdev-snapshot-delete-internal-sync definition into qapi/block.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 27 ---
 qapi/block.json  | 27 +++
 2 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 8a6e192..eebb632 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1213,33 +1213,6 @@
   'data': { 'actions': [ 'TransactionAction' ] } }
 
 ##
-# @blockdev-snapshot-delete-internal-sync
-#
-# Synchronously delete an internal snapshot of a block device, when the format
-# of the image used support it. The snapshot is identified by name or id or
-# both. One of the name or id is required. Return SnapshotInfo for the
-# successfully deleted snapshot.
-#
-# @device: the name of the device to delete the snapshot from
-#
-# @id: optional the snapshot's ID to be deleted
-#
-# @name: optional the snapshot's name to be deleted
-#
-# Returns: SnapshotInfo on success
-#  If @device is not a valid block device, DeviceNotFound
-#  If snapshot not found, GenericError
-#  If the format of the image used does not support it,
-#  BlockFormatFeatureNotSupported
-#  If @id and @name are both not specified, GenericError
-#
-# Since 1.7
-##
-{ 'command': 'blockdev-snapshot-delete-internal-sync',
-  'data': { 'device': 'str', '*id': 'str', '*name': 'str'},
-  'returns': 'SnapshotInfo' }
-
-##
 # @human-monitor-command:
 #
 # Execute a command on the human monitor and return the output.
diff --git a/qapi/block.json b/qapi/block.json
index 830751c..fe4812e 100644
--- a/qapi/block.json
+++ b/qapi/block.json
@@ -75,3 +75,30 @@
 { 'command': 'blockdev-snapshot-internal-sync',
   'data': 'BlockdevSnapshotInternal' }
 
+##
+# @blockdev-snapshot-delete-internal-sync
+#
+# Synchronously delete an internal snapshot of a block device, when the format
+# of the image used support it. The snapshot is identified by name or id or
+# both. One of the name or id is required. Return SnapshotInfo for the
+# successfully deleted snapshot.
+#
+# @device: the name of the device to delete the snapshot from
+#
+# @id: optional the snapshot's ID to be deleted
+#
+# @name: optional the snapshot's name to be deleted
+#
+# Returns: SnapshotInfo on success
+#  If @device is not a valid block device, DeviceNotFound
+#  If snapshot not found, GenericError
+#  If the format of the image used does not support it,
+#  BlockFormatFeatureNotSupported
+#  If @id and @name are both not specified, GenericError
+#
+# Since 1.7
+##
+{ 'command': 'blockdev-snapshot-delete-internal-sync',
+  'data': { 'device': 'str', '*id': 'str', '*name': 'str'},
+  'returns': 'SnapshotInfo' }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 50/72] qapi: Extract BlockdevOptionsBase definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 37 -
 qapi/block-core.json | 37 +
 2 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 8162c9a..59a7623 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3162,43 +3162,6 @@
   'returns': ['RxFilterInfo'] }
 
 ##
-# @BlockdevOptionsBase
-#
-# Options that are available for all block devices, independent of the block
-# driver.
-#
-# @driver:block driver name
-# @id:#optional id by which the new block device can be referred 
to.
-# This is a required option on the top level of blockdev-add, 
and
-# currently not allowed on any other level.
-# @node-name: #optional the name of a block driver state node (Since 2.0)
-# @discard:   #optional discard-related options (default: ignore)
-# @cache: #optional cache-related options
-# @aio:   #optional AIO backend (default: threads)
-# @rerror:#optional how to handle read errors on the device
-# (default: report)
-# @werror:#optional how to handle write errors on the device
-# (default: enospc)
-# @read-only: #optional whether the block device should be read-only
-# (default: false)
-# @detect-zeroes: #optional detect and optimize zero writes (Since 2.1)
-# (default: off)
-#
-# Since: 1.7
-##
-{ 'type': 'BlockdevOptionsBase',
-  'data': { 'driver': 'BlockdevDriver',
-'*id': 'str',
-'*node-name': 'str',
-'*discard': 'BlockdevDiscardOptions',
-'*cache': 'BlockdevCacheOptions',
-'*aio': 'BlockdevAioOptions',
-'*rerror': 'BlockdevOnError',
-'*werror': 'BlockdevOnError',
-'*read-only': 'bool',
-'*detect-zeroes': 'BlockdevDetectZeroesOptions' } }
-
-##
 # @BlockdevOptionsFile
 #
 # Driver specific block device options for the file backend and similar
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 95362a8..2038ef4 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1115,3 +1115,40 @@
 'blkverify', 'bochs', 'cloop', 'cow', 'dmg', 'parallels', 'qcow',
 'qcow2', 'qed', 'raw', 'vdi', 'vhdx', 'vmdk', 'vpc', 'quorum' ] }
 
+##
+# @BlockdevOptionsBase
+#
+# Options that are available for all block devices, independent of the block
+# driver.
+#
+# @driver:block driver name
+# @id:#optional id by which the new block device can be referred 
to.
+# This is a required option on the top level of blockdev-add, 
and
+# currently not allowed on any other level.
+# @node-name: #optional the name of a block driver state node (Since 2.0)
+# @discard:   #optional discard-related options (default: ignore)
+# @cache: #optional cache-related options
+# @aio:   #optional AIO backend (default: threads)
+# @rerror:#optional how to handle read errors on the device
+# (default: report)
+# @werror:#optional how to handle write errors on the device
+# (default: enospc)
+# @read-only: #optional whether the block device should be read-only
+# (default: false)
+# @detect-zeroes: #optional detect and optimize zero writes (Since 2.1)
+# (default: off)
+#
+# Since: 1.7
+##
+{ 'type': 'BlockdevOptionsBase',
+  'data': { 'driver': 'BlockdevDriver',
+'*id': 'str',
+'*node-name': 'str',
+'*discard': 'BlockdevDiscardOptions',
+'*cache': 'BlockdevCacheOptions',
+'*aio': 'BlockdevAioOptions',
+'*rerror': 'BlockdevOnError',
+'*werror': 'BlockdevOnError',
+'*read-only': 'bool',
+'*detect-zeroes': 'BlockdevDetectZeroesOptions' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 62/72] qapi: Extract BlockdevOptions definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 46 --
 qapi/block-core.json | 46 ++
 2 files changed, 46 insertions(+), 46 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 9e7138e..53e546b 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3162,52 +3162,6 @@
   'returns': ['RxFilterInfo'] }
 
 ##
-# @BlockdevOptions
-#
-# Options for creating a block device.
-#
-# Since: 1.7
-##
-{ 'union': 'BlockdevOptions',
-  'base': 'BlockdevOptionsBase',
-  'discriminator': 'driver',
-  'data': {
-  'file':   'BlockdevOptionsFile',
-  'host_device':'BlockdevOptionsFile',
-  'host_cdrom': 'BlockdevOptionsFile',
-  'host_floppy':'BlockdevOptionsFile',
-  'http':   'BlockdevOptionsFile',
-  'https':  'BlockdevOptionsFile',
-  'ftp':'BlockdevOptionsFile',
-  'ftps':   'BlockdevOptionsFile',
-  'tftp':   'BlockdevOptionsFile',
-# TODO gluster: Wait for structured options
-# TODO iscsi: Wait for structured options
-# TODO nbd: Should take InetSocketAddress for 'host'?
-# TODO nfs: Wait for structured options
-# TODO rbd: Wait for structured options
-# TODO sheepdog: Wait for structured options
-# TODO ssh: Should take InetSocketAddress for 'host'?
-  'vvfat':  'BlockdevOptionsVVFAT',
-  'blkdebug':   'BlockdevOptionsBlkdebug',
-  'blkverify':  'BlockdevOptionsBlkverify',
-  'bochs':  'BlockdevOptionsGenericFormat',
-  'cloop':  'BlockdevOptionsGenericFormat',
-  'cow':'BlockdevOptionsGenericCOWFormat',
-  'dmg':'BlockdevOptionsGenericFormat',
-  'parallels':  'BlockdevOptionsGenericFormat',
-  'qcow':   'BlockdevOptionsGenericCOWFormat',
-  'qcow2':  'BlockdevOptionsQcow2',
-  'qed':'BlockdevOptionsGenericCOWFormat',
-  'raw':'BlockdevOptionsGenericFormat',
-  'vdi':'BlockdevOptionsGenericFormat',
-  'vhdx':   'BlockdevOptionsGenericFormat',
-  'vmdk':   'BlockdevOptionsGenericCOWFormat',
-  'vpc':'BlockdevOptionsGenericFormat',
-  'quorum': 'BlockdevOptionsQuorum'
-  } }
-
-##
 # @BlockdevRef
 #
 # Reference to a block device.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 2373ef0..eb6f12b 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1372,3 +1372,49 @@
 'children': [ 'BlockdevRef' ],
 'vote-threshold': 'int', '*rewrite-corrupted': 'bool' } }
 
+##
+# @BlockdevOptions
+#
+# Options for creating a block device.
+#
+# Since: 1.7
+##
+{ 'union': 'BlockdevOptions',
+  'base': 'BlockdevOptionsBase',
+  'discriminator': 'driver',
+  'data': {
+  'file':   'BlockdevOptionsFile',
+  'host_device':'BlockdevOptionsFile',
+  'host_cdrom': 'BlockdevOptionsFile',
+  'host_floppy':'BlockdevOptionsFile',
+  'http':   'BlockdevOptionsFile',
+  'https':  'BlockdevOptionsFile',
+  'ftp':'BlockdevOptionsFile',
+  'ftps':   'BlockdevOptionsFile',
+  'tftp':   'BlockdevOptionsFile',
+# TODO gluster: Wait for structured options
+# TODO iscsi: Wait for structured options
+# TODO nbd: Should take InetSocketAddress for 'host'?
+# TODO nfs: Wait for structured options
+# TODO rbd: Wait for structured options
+# TODO sheepdog: Wait for structured options
+# TODO ssh: Should take InetSocketAddress for 'host'?
+  'vvfat':  'BlockdevOptionsVVFAT',
+  'blkdebug':   'BlockdevOptionsBlkdebug',
+  'blkverify':  'BlockdevOptionsBlkverify',
+  'bochs':  'BlockdevOptionsGenericFormat',
+  'cloop':  'BlockdevOptionsGenericFormat',
+  'cow':'BlockdevOptionsGenericCOWFormat',
+  'dmg':'BlockdevOptionsGenericFormat',
+  'parallels':  'BlockdevOptionsGenericFormat',
+  'qcow':   'BlockdevOptionsGenericCOWFormat',
+  'qcow2':  'BlockdevOptionsQcow2',
+  'qed':'BlockdevOptionsGenericCOWFormat',
+  'raw':'BlockdevOptionsGenericFormat',
+  'vdi':'BlockdevOptionsGenericFormat',
+  'vhdx':   'BlockdevOptionsGenericFormat',
+  'vmdk':   'BlockdevOptionsGenericCOWFormat',
+  'vpc':'BlockdevOptionsGenericFormat',
+  'quorum': 'BlockdevOptionsQuorum'
+  } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 09/72] qapi: Extract ImageInfoSpecificQCow2 definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 21 -
 qapi/block-core.json | 21 +
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 2507681..0c517f4 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -184,27 +184,6 @@
 'guest-panicked' ] }
 
 ##
-# @ImageInfoSpecificVmdk:
-#
-# @create-type: The create type of VMDK image
-#
-# @cid: Content id of image
-#
-# @parent-cid: Parent VMDK image's cid
-#
-# @extents: List of extent files
-#
-# Since: 1.7
-##
-{ 'type': 'ImageInfoSpecificVmdk',
-  'data': {
-  'create-type': 'str',
-  'cid': 'int',
-  'parent-cid': 'int',
-  'extents': ['ImageInfo']
-  } }
-
-##
 # @ImageInfoSpecific:
 #
 # A discriminated record of image format specific information structures.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 3897c57..ed853d9 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -46,3 +46,24 @@
   '*lazy-refcounts': 'bool'
   } }
 
+##
+# @ImageInfoSpecificVmdk:
+#
+# @create-type: The create type of VMDK image
+#
+# @cid: Content id of image
+#
+# @parent-cid: Parent VMDK image's cid
+#
+# @extents: List of extent files
+#
+# Since: 1.7
+##
+{ 'type': 'ImageInfoSpecificVmdk',
+  'data': {
+  'create-type': 'str',
+  'cid': 'int',
+  'parent-cid': 'int',
+  'extents': ['ImageInfo']
+  } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 47/72] qapi: Extract BlockdevAioOptions definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 13 -
 qapi/block-core.json | 13 +
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 04e2e5d..3eb5a13 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3162,19 +3162,6 @@
   'returns': ['RxFilterInfo'] }
 
 ##
-# @BlockdevAioOptions
-#
-# Selects the AIO backend to handle I/O requests
-#
-# @threads: Use qemu's thread pool
-# @native:  Use native AIO backend (only Linux and Windows)
-#
-# Since: 1.7
-##
-{ 'enum': 'BlockdevAioOptions',
-  'data': [ 'threads', 'native' ] }
-
-##
 # @BlockdevCacheOptions
 #
 # Includes cache-related options for block devices
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 96013bf..f0b7bd2 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1069,3 +1069,16 @@
 { 'enum': 'BlockdevDetectZeroesOptions',
   'data': [ 'off', 'on', 'unmap' ] }
 
+##
+# @BlockdevAioOptions
+#
+# Selects the AIO backend to handle I/O requests
+#
+# @threads: Use qemu's thread pool
+# @native:  Use native AIO backend (only Linux and Windows)
+#
+# Since: 1.7
+##
+{ 'enum': 'BlockdevAioOptions',
+  'data': [ 'threads', 'native' ] }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 64/72] qapi: Extract blockdev-add definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 11 ---
 qapi/block-core.json | 11 +++
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 0e38f83..c888d23 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3162,17 +3162,6 @@
   'returns': ['RxFilterInfo'] }
 
 ##
-# @blockdev-add:
-#
-# Creates a new block device.
-#
-# @options: block device options for the new device
-#
-# Since: 1.7
-##
-{ 'command': 'blockdev-add', 'data': { 'options': 'BlockdevOptions' } }
-
-##
 # @InputButton
 #
 # Button of a pointer input device (mouse, tablet).
diff --git a/qapi/block-core.json b/qapi/block-core.json
index b8b4fe1..f8d9914 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1435,3 +1435,14 @@
   'data': { 'definition': 'BlockdevOptions',
 'reference': 'str' } }
 
+##
+# @blockdev-add:
+#
+# Creates a new block device.
+#
+# @options: block device options for the new device
+#
+# Since: 1.7
+##
+{ 'command': 'blockdev-add', 'data': { 'options': 'BlockdevOptions' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 42/72] qapi: Extract block-job-resume definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 20 
 qapi/block-core.json | 20 
 2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 17d92df..3d4254c 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1621,26 +1621,6 @@
   'data': {'device': 'str', 'target': 'str', '*arg': 'str'} }
 
 ##
-# @block-job-resume:
-#
-# Resume an active background block operation.
-#
-# This command returns immediately after resuming a paused background block
-# operation.  It is an error to call this command if no operation is in
-# progress.  Resuming an already running job is not an error.
-#
-# This command also clears the error status of the job.
-#
-# @device: the device name
-#
-# Returns: Nothing on success
-#  If no background operation is active on this device, DeviceNotActive
-#
-# Since: 1.3
-##
-{ 'command': 'block-job-resume', 'data': { 'device': 'str' } }
-
-##
 # @block-job-complete:
 #
 # Manually trigger completion of an active background block operation.  This
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 51c941a..540b7ee 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -961,3 +961,23 @@
 ##
 { 'command': 'block-job-pause', 'data': { 'device': 'str' } }
 
+##
+# @block-job-resume:
+#
+# Resume an active background block operation.
+#
+# This command returns immediately after resuming a paused background block
+# operation.  It is an error to call this command if no operation is in
+# progress.  Resuming an already running job is not an error.
+#
+# This command also clears the error status of the job.
+#
+# @device: the device name
+#
+# Returns: Nothing on success
+#  If no background operation is active on this device, DeviceNotActive
+#
+# Since: 1.3
+##
+{ 'command': 'block-job-resume', 'data': { 'device': 'str' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 58/72] qapi: Extract BlkdebugSetStateOptions definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 20 
 qapi/block-core.json | 20 
 2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index d2a25c4..ff85d1c 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3162,26 +3162,6 @@
   'returns': ['RxFilterInfo'] }
 
 ##
-# @BlkdebugSetStateOptions
-#
-# Describes a single state-change event for blkdebug.
-#
-# @event:   trigger event
-#
-# @state:   #optional the current state identifier blkdebug needs to be in;
-#   defaults to "any"
-#
-# @new_state:   the state identifier blkdebug is supposed to assume if
-#   this event is triggered
-#
-# Since: 2.0
-##
-{ 'type': 'BlkdebugSetStateOptions',
-  'data': { 'event': 'BlkdebugEvent',
-'*state': 'int',
-'new_state': 'int' } }
-
-##
 # @BlockdevOptionsBlkdebug
 #
 # Driver specific block device options for blkdebug.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 5aba01d..82299b2 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1291,3 +1291,23 @@
 '*once': 'bool',
 '*immediately': 'bool' } }
 
+##
+# @BlkdebugSetStateOptions
+#
+# Describes a single state-change event for blkdebug.
+#
+# @event:   trigger event
+#
+# @state:   #optional the current state identifier blkdebug needs to be in;
+#   defaults to "any"
+#
+# @new_state:   the state identifier blkdebug is supposed to assume if
+#   this event is triggered
+#
+# Since: 2.0
+##
+{ 'type': 'BlkdebugSetStateOptions',
+  'data': { 'event': 'BlkdebugEvent',
+'*state': 'int',
+'new_state': 'int' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 40/72] qapi: Extrat block-job-cancel definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 30 --
 qapi/block-core.json | 30 ++
 2 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 307fc54..75d76f9 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1621,36 +1621,6 @@
   'data': {'device': 'str', 'target': 'str', '*arg': 'str'} }
 
 ##
-# @block-job-cancel:
-#
-# Stop an active background block operation.
-#
-# This command returns immediately after marking the active background block
-# operation for cancellation.  It is an error to call this command if no
-# operation is in progress.
-#
-# The operation will cancel as soon as possible and then emit the
-# BLOCK_JOB_CANCELLED event.  Before that happens the job is still visible when
-# enumerated using query-block-jobs.
-#
-# For streaming, the image file retains its backing file unless the streaming
-# operation happens to complete just as it is being cancelled.  A new streaming
-# operation can be started at a later time to finish copying all data from the
-# backing file.
-#
-# @device: the device name
-#
-# @force: #optional whether to allow cancellation of a paused job (default
-# false).  Since 1.3.
-#
-# Returns: Nothing on success
-#  If no background operation is active on this device, DeviceNotActive
-#
-# Since: 1.1
-##
-{ 'command': 'block-job-cancel', 'data': { 'device': 'str', '*force': 'bool' } 
}
-
-##
 # @block-job-pause:
 #
 # Pause an active background block operation.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 48b2fc3..6a3de86 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -908,3 +908,33 @@
 { 'command': 'block-job-set-speed',
   'data': { 'device': 'str', 'speed': 'int' } }
 
+##
+# @block-job-cancel:
+#
+# Stop an active background block operation.
+#
+# This command returns immediately after marking the active background block
+# operation for cancellation.  It is an error to call this command if no
+# operation is in progress.
+#
+# The operation will cancel as soon as possible and then emit the
+# BLOCK_JOB_CANCELLED event.  Before that happens the job is still visible when
+# enumerated using query-block-jobs.
+#
+# For streaming, the image file retains its backing file unless the streaming
+# operation happens to complete just as it is being cancelled.  A new streaming
+# operation can be started at a later time to finish copying all data from the
+# backing file.
+#
+# @device: the device name
+#
+# @force: #optional whether to allow cancellation of a paused job (default
+# false).  Since 1.3.
+#
+# Returns: Nothing on success
+#  If no background operation is active on this device, DeviceNotActive
+#
+# Since: 1.1
+##
+{ 'command': 'block-job-cancel', 'data': { 'device': 'str', '*force': 'bool' } 
}
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 48/72] qapi: Extract BlockdevCacheOptions definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 18 --
 qapi/block-core.json | 18 ++
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 3eb5a13..b046fd8 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3162,24 +3162,6 @@
   'returns': ['RxFilterInfo'] }
 
 ##
-# @BlockdevCacheOptions
-#
-# Includes cache-related options for block devices
-#
-# @writeback:   #optional enables writeback mode for any caches (default: true)
-# @direct:  #optional enables use of O_DIRECT (bypass the host page cache;
-#   default: false)
-# @no-flush:#optional ignore any flush requests for the device (default:
-#   false)
-#
-# Since: 1.7
-##
-{ 'type': 'BlockdevCacheOptions',
-  'data': { '*writeback': 'bool',
-'*direct': 'bool',
-'*no-flush': 'bool' } }
-
-##
 # @BlockdevDriver
 #
 # Drivers that are supported in block device operations.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index f0b7bd2..104d876 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1082,3 +1082,21 @@
 { 'enum': 'BlockdevAioOptions',
   'data': [ 'threads', 'native' ] }
 
+##
+# @BlockdevCacheOptions
+#
+# Includes cache-related options for block devices
+#
+# @writeback:   #optional enables writeback mode for any caches (default: true)
+# @direct:  #optional enables use of O_DIRECT (bypass the host page cache;
+#   default: false)
+# @no-flush:#optional ignore any flush requests for the device (default:
+#   false)
+#
+# Since: 1.7
+##
+{ 'type': 'BlockdevCacheOptions',
+  'data': { '*writeback': 'bool',
+'*direct': 'bool',
+'*no-flush': 'bool' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 45/72] qapi: Extract BlockdevDiscardOptions definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 14 --
 qapi/block-core.json | 13 +
 2 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 5ae556c..6c29cb8 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3161,20 +3161,6 @@
 { 'command': 'query-rx-filter', 'data': { '*name': 'str' },
   'returns': ['RxFilterInfo'] }
 
-
-##
-# @BlockdevDiscardOptions
-#
-# Determines how to handle discard requests.
-#
-# @ignore:  Ignore the request
-# @unmap:   Forward as an unmap request
-#
-# Since: 1.7
-##
-{ 'enum': 'BlockdevDiscardOptions',
-  'data': [ 'ignore', 'unmap' ] }
-
 ##
 # @BlockdevDetectZeroesOptions
 #
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 1049a05..85cb470 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1040,3 +1040,16 @@
   'data': { 'device': 'str', 'target-reference': 'str',
 '*new-node-name': 'str' } }
 
+##
+# @BlockdevDiscardOptions
+#
+# Determines how to handle discard requests.
+#
+# @ignore:  Ignore the request
+# @unmap:   Forward as an unmap request
+#
+# Since: 1.7
+##
+{ 'enum': 'BlockdevDiscardOptions',
+  'data': [ 'ignore', 'unmap' ] }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 37/72] qapi: Extract block_set_io_throttle definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 46 --
 qapi/block-core.json | 46 ++
 2 files changed, 46 insertions(+), 46 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index b869ab9..844784d 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1621,52 +1621,6 @@
   'data': {'device': 'str', 'target': 'str', '*arg': 'str'} }
 
 ##
-# @block_set_io_throttle:
-#
-# Change I/O throttle limits for a block drive.
-#
-# @device: The name of the device
-#
-# @bps: total throughput limit in bytes per second
-#
-# @bps_rd: read throughput limit in bytes per second
-#
-# @bps_wr: write throughput limit in bytes per second
-#
-# @iops: total I/O operations per second
-#
-# @ops_rd: read I/O operations per second
-#
-# @iops_wr: write I/O operations per second
-#
-# @bps_max: #optional total max in bytes (Since 1.7)
-#
-# @bps_rd_max: #optional read max in bytes (Since 1.7)
-#
-# @bps_wr_max: #optional write max in bytes (Since 1.7)
-#
-# @iops_max: #optional total I/O operations max (Since 1.7)
-#
-# @iops_rd_max: #optional read I/O operations max (Since 1.7)
-#
-# @iops_wr_max: #optional write I/O operations max (Since 1.7)
-#
-# @iops_size: #optional an I/O size in bytes (Since 1.7)
-#
-# Returns: Nothing on success
-#  If @device is not a valid block device, DeviceNotFound
-#
-# Since: 1.1
-##
-{ 'command': 'block_set_io_throttle',
-  'data': { 'device': 'str', 'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int',
-'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int',
-'*bps_max': 'int', '*bps_rd_max': 'int',
-'*bps_wr_max': 'int', '*iops_max': 'int',
-'*iops_rd_max': 'int', '*iops_wr_max': 'int',
-'*iops_size': 'int' } }
-
-##
 # @block-stream:
 #
 # Copy data from a backing file into a block device.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index b75bccb..20515e6 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -802,3 +802,49 @@
 '*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
 '*on-target-error': 'BlockdevOnError' } }
 
+##
+# @block_set_io_throttle:
+#
+# Change I/O throttle limits for a block drive.
+#
+# @device: The name of the device
+#
+# @bps: total throughput limit in bytes per second
+#
+# @bps_rd: read throughput limit in bytes per second
+#
+# @bps_wr: write throughput limit in bytes per second
+#
+# @iops: total I/O operations per second
+#
+# @ops_rd: read I/O operations per second
+#
+# @iops_wr: write I/O operations per second
+#
+# @bps_max: #optional total max in bytes (Since 1.7)
+#
+# @bps_rd_max: #optional read max in bytes (Since 1.7)
+#
+# @bps_wr_max: #optional write max in bytes (Since 1.7)
+#
+# @iops_max: #optional total I/O operations max (Since 1.7)
+#
+# @iops_rd_max: #optional read I/O operations max (Since 1.7)
+#
+# @iops_wr_max: #optional write I/O operations max (Since 1.7)
+#
+# @iops_size: #optional an I/O size in bytes (Since 1.7)
+#
+# Returns: Nothing on success
+#  If @device is not a valid block device, DeviceNotFound
+#
+# Since: 1.1
+##
+{ 'command': 'block_set_io_throttle',
+  'data': { 'device': 'str', 'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int',
+'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int',
+'*bps_max': 'int', '*bps_rd_max': 'int',
+'*bps_wr_max': 'int', '*iops_max': 'int',
+'*iops_rd_max': 'int', '*iops_wr_max': 'int',
+'*iops_size': 'int' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 33/72] qapi: Extract block-commit definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 43 ---
 qapi/block-core.json | 43 +++
 2 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 09b864f..02958cc 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1338,49 +1338,6 @@
   'returns': 'str' }
 
 ##
-# @block-commit
-#
-# Live commit of data from overlay image nodes into backing nodes - i.e.,
-# writes data between 'top' and 'base' into 'base'.
-#
-# @device:  the name of the device
-#
-# @base:   #optional The file name of the backing image to write data into.
-#If not specified, this is the deepest backing image
-#
-# @top:  The file name of the backing image within the image chain,
-#which contains the topmost data to be committed down.
-#
-#If top == base, that is an error.
-#If top == active, the job will not be completed by itself,
-#user needs to complete the job with the block-job-complete
-#command after getting the ready event. (Since 2.0)
-#
-#If the base image is smaller than top, then the base image
-#will be resized to be the same size as top.  If top is
-#smaller than the base image, the base will not be
-#truncated.  If you want the base image size to match the
-#size of the smaller top, you can safely truncate it
-#yourself once the commit operation successfully completes.
-#
-#
-# @speed:  #optional the maximum speed, in bytes per second
-#
-# Returns: Nothing on success
-#  If commit or stream is already active on this device, DeviceInUse
-#  If @device does not exist, DeviceNotFound
-#  If image commit is not supported by this device, NotSupported
-#  If @base or @top is invalid, a generic error is returned
-#  If @speed is invalid, InvalidParameter
-#
-# Since: 1.3
-#
-##
-{ 'command': 'block-commit',
-  'data': { 'device': 'str', '*base': 'str', 'top': 'str',
-'*speed': 'int' } }
-
-##
 # @drive-backup
 #
 # Start a point-in-time copy of a block device to a new destination.  The
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 1f482f1..75fe7ce 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -679,3 +679,46 @@
 { 'command': 'blockdev-snapshot-sync',
   'data': 'BlockdevSnapshot' }
 
+##
+# @block-commit
+#
+# Live commit of data from overlay image nodes into backing nodes - i.e.,
+# writes data between 'top' and 'base' into 'base'.
+#
+# @device:  the name of the device
+#
+# @base:   #optional The file name of the backing image to write data into.
+#If not specified, this is the deepest backing image
+#
+# @top:  The file name of the backing image within the image chain,
+#which contains the topmost data to be committed down.
+#
+#If top == base, that is an error.
+#If top == active, the job will not be completed by itself,
+#user needs to complete the job with the block-job-complete
+#command after getting the ready event. (Since 2.0)
+#
+#If the base image is smaller than top, then the base image
+#will be resized to be the same size as top.  If top is
+#smaller than the base image, the base will not be
+#truncated.  If you want the base image size to match the
+#size of the smaller top, you can safely truncate it
+#yourself once the commit operation successfully completes.
+#
+#
+# @speed:  #optional the maximum speed, in bytes per second
+#
+# Returns: Nothing on success
+#  If commit or stream is already active on this device, DeviceInUse
+#  If @device does not exist, DeviceNotFound
+#  If image commit is not supported by this device, NotSupported
+#  If @base or @top is invalid, a generic error is returned
+#  If @speed is invalid, InvalidParameter
+#
+# Since: 1.3
+#
+##
+{ 'command': 'block-commit',
+  'data': { 'device': 'str', '*base': 'str', 'top': 'str',
+'*speed': 'int' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 46/72] qapi: Extract BlockdevDetectZeroesOptions definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 16 
 qapi/block-core.json | 16 
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 6c29cb8..04e2e5d 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3162,22 +3162,6 @@
   'returns': ['RxFilterInfo'] }
 
 ##
-# @BlockdevDetectZeroesOptions
-#
-# Describes the operation mode for the automatic conversion of plain
-# zero writes by the OS to driver specific optimized zero write commands.
-#
-# @off:  Disabled (default)
-# @on:   Enabled
-# @unmap:Enabled and even try to unmap blocks if possible. This requires
-#also that @BlockdevDiscardOptions is set to unmap for this device.
-#
-# Since: 2.1
-##
-{ 'enum': 'BlockdevDetectZeroesOptions',
-  'data': [ 'off', 'on', 'unmap' ] }
-
-##
 # @BlockdevAioOptions
 #
 # Selects the AIO backend to handle I/O requests
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 85cb470..96013bf 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1053,3 +1053,19 @@
 { 'enum': 'BlockdevDiscardOptions',
   'data': [ 'ignore', 'unmap' ] }
 
+##
+# @BlockdevDetectZeroesOptions
+#
+# Describes the operation mode for the automatic conversion of plain
+# zero writes by the OS to driver specific optimized zero write commands.
+#
+# @off:  Disabled (default)
+# @on:   Enabled
+# @unmap:Enabled and even try to unmap blocks if possible. This requires
+#also that @BlockdevDiscardOptions is set to unmap for this device.
+#
+# Since: 2.1
+##
+{ 'enum': 'BlockdevDetectZeroesOptions',
+  'data': [ 'off', 'on', 'unmap' ] }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 38/72] qapi: Extract block-stream definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 38 --
 qapi/block-core.json | 38 ++
 2 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 844784d..3c71c16 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1621,44 +1621,6 @@
   'data': {'device': 'str', 'target': 'str', '*arg': 'str'} }
 
 ##
-# @block-stream:
-#
-# Copy data from a backing file into a block device.
-#
-# The block streaming operation is performed in the background until the entire
-# backing file has been copied.  This command returns immediately once 
streaming
-# has started.  The status of ongoing block streaming operations can be checked
-# with query-block-jobs.  The operation can be stopped before it has completed
-# using the block-job-cancel command.
-#
-# If a base file is specified then sectors are not copied from that base file 
and
-# its backing chain.  When streaming completes the image file will have the 
base
-# file as its backing file.  This can be used to stream a subset of the backing
-# file chain instead of flattening the entire image.
-#
-# On successful completion the image file is updated to drop the backing file
-# and the BLOCK_JOB_COMPLETED event is emitted.
-#
-# @device: the device name
-#
-# @base:   #optional the common backing file name
-#
-# @speed:  #optional the maximum speed, in bytes per second
-#
-# @on-error: #optional the action to take on an error (default report).
-#'stop' and 'enospc' can only be used if the block device
-#supports io-status (see BlockInfo).  Since 1.3.
-#
-# Returns: Nothing on success
-#  If @device does not exist, DeviceNotFound
-#
-# Since: 1.1
-##
-{ 'command': 'block-stream',
-  'data': { 'device': 'str', '*base': 'str', '*speed': 'int',
-'*on-error': 'BlockdevOnError' } }
-
-##
 # @block-job-set-speed:
 #
 # Set maximum speed for a background block operation.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 20515e6..a91f21a 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -848,3 +848,41 @@
 '*iops_rd_max': 'int', '*iops_wr_max': 'int',
 '*iops_size': 'int' } }
 
+##
+# @block-stream:
+#
+# Copy data from a backing file into a block device.
+#
+# The block streaming operation is performed in the background until the entire
+# backing file has been copied.  This command returns immediately once 
streaming
+# has started.  The status of ongoing block streaming operations can be checked
+# with query-block-jobs.  The operation can be stopped before it has completed
+# using the block-job-cancel command.
+#
+# If a base file is specified then sectors are not copied from that base file 
and
+# its backing chain.  When streaming completes the image file will have the 
base
+# file as its backing file.  This can be used to stream a subset of the backing
+# file chain instead of flattening the entire image.
+#
+# On successful completion the image file is updated to drop the backing file
+# and the BLOCK_JOB_COMPLETED event is emitted.
+#
+# @device: the device name
+#
+# @base:   #optional the common backing file name
+#
+# @speed:  #optional the maximum speed, in bytes per second
+#
+# @on-error: #optional the action to take on an error (default report).
+#'stop' and 'enospc' can only be used if the block device
+#supports io-status (see BlockInfo).  Since 1.3.
+#
+# Returns: Nothing on success
+#  If @device does not exist, DeviceNotFound
+#
+# Since: 1.1
+##
+{ 'command': 'block-stream',
+  'data': { 'device': 'str', '*base': 'str', '*speed': 'int',
+'*on-error': 'BlockdevOnError' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 39/72] qapi: Extract block-job-set-speed definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 22 --
 qapi/block-core.json | 22 ++
 2 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 3c71c16..307fc54 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1621,28 +1621,6 @@
   'data': {'device': 'str', 'target': 'str', '*arg': 'str'} }
 
 ##
-# @block-job-set-speed:
-#
-# Set maximum speed for a background block operation.
-#
-# This command can only be issued when there is an active block job.
-#
-# Throttling can be disabled by setting the speed to 0.
-#
-# @device: the device name
-#
-# @speed:  the maximum speed, in bytes per second, or 0 for unlimited.
-#  Defaults to 0.
-#
-# Returns: Nothing on success
-#  If no background operation is active on this device, DeviceNotActive
-#
-# Since: 1.1
-##
-{ 'command': 'block-job-set-speed',
-  'data': { 'device': 'str', 'speed': 'int' } }
-
-##
 # @block-job-cancel:
 #
 # Stop an active background block operation.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index a91f21a..48b2fc3 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -886,3 +886,25 @@
   'data': { 'device': 'str', '*base': 'str', '*speed': 'int',
 '*on-error': 'BlockdevOnError' } }
 
+##
+# @block-job-set-speed:
+#
+# Set maximum speed for a background block operation.
+#
+# This command can only be issued when there is an active block job.
+#
+# Throttling can be disabled by setting the speed to 0.
+#
+# @device: the device name
+#
+# @speed:  the maximum speed, in bytes per second, or 0 for unlimited.
+#  Defaults to 0.
+#
+# Returns: Nothing on success
+#  If no background operation is active on this device, DeviceNotActive
+#
+# Since: 1.1
+##
+{ 'command': 'block-job-set-speed',
+  'data': { 'device': 'str', 'speed': 'int' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 70/72] qapi: Extract nbd-server-start definition into qapi/block.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 17 -
 qapi/block.json  | 17 +
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index b67c883..614b126 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -2463,23 +2463,6 @@
 { 'command': 'screendump', 'data': {'filename': 'str'} }
 
 ##
-# @nbd-server-start:
-#
-# Start an NBD server listening on the given host and port.  Block
-# devices can then be exported using @nbd-server-add.  The NBD
-# server will present them as named exports; for example, another
-# QEMU instance could refer to them as "nbd:HOST:PORT:exportname=NAME".
-#
-# @addr: Address on which to listen.
-#
-# Returns: error if the server is already running.
-#
-# Since: 1.3.0
-##
-{ 'command': 'nbd-server-start',
-  'data': { 'addr': 'SocketAddress' } }
-
-##
 # @nbd-server-add:
 #
 # Export a device to QEMU's embedded NBD server.
diff --git a/qapi/block.json b/qapi/block.json
index de4b144..690c871 100644
--- a/qapi/block.json
+++ b/qapi/block.json
@@ -121,3 +121,20 @@
 ##
 { 'command': 'eject', 'data': {'device': 'str', '*force': 'bool'} }
 
+##
+# @nbd-server-start:
+#
+# Start an NBD server listening on the given host and port.  Block
+# devices can then be exported using @nbd-server-add.  The NBD
+# server will present them as named exports; for example, another
+# QEMU instance could refer to them as "nbd:HOST:PORT:exportname=NAME".
+#
+# @addr: Address on which to listen.
+#
+# Returns: error if the server is already running.
+#
+# Since: 1.3.0
+##
+{ 'command': 'nbd-server-start',
+  'data': { 'addr': 'SocketAddress' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 36/72] qapi: Extract drive-mirror definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 51 ---
 qapi/block-core.json | 51 +++
 2 files changed, 51 insertions(+), 51 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index a671db7..b869ab9 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1338,57 +1338,6 @@
   'returns': 'str' }
 
 ##
-# @drive-mirror
-#
-# Start mirroring a block device's writes to a new destination.
-#
-# @device:  the name of the device whose writes should be mirrored.
-#
-# @target: the target of the new image. If the file exists, or if it
-#  is a device, the existing file/device will be used as the new
-#  destination.  If it does not exist, a new file will be created.
-#
-# @format: #optional the format of the new destination, default is to
-#  probe if @mode is 'existing', else the format of the source
-#
-# @mode: #optional whether and how QEMU should create a new image, default is
-#'absolute-paths'.
-#
-# @speed:  #optional the maximum speed, in bytes per second
-#
-# @sync: what parts of the disk image should be copied to the destination
-#(all the disk, only the sectors allocated in the topmost image, or
-#only new I/O).
-#
-# @granularity: #optional granularity of the dirty bitmap, default is 64K
-#   if the image format doesn't have clusters, 4K if the clusters
-#   are smaller than that, else the cluster size.  Must be a
-#   power of 2 between 512 and 64M (since 1.4).
-#
-# @buf-size: #optional maximum amount of data in flight from source to
-#target (since 1.4).
-#
-# @on-source-error: #optional the action to take on an error on the source,
-#   default 'report'.  'stop' and 'enospc' can only be used
-#   if the block device supports io-status (see BlockInfo).
-#
-# @on-target-error: #optional the action to take on an error on the target,
-#   default 'report' (no limitations, since this applies to
-#   a different block device than @device).
-#
-# Returns: nothing on success
-#  If @device is not a valid block device, DeviceNotFound
-#
-# Since 1.3
-##
-{ 'command': 'drive-mirror',
-  'data': { 'device': 'str', 'target': 'str', '*format': 'str',
-'sync': 'MirrorSyncMode', '*mode': 'NewImageMode',
-'*speed': 'int', '*granularity': 'uint32',
-'*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
-'*on-target-error': 'BlockdevOnError' } }
-
-##
 # @migrate_cancel
 #
 # Cancel the current executing migration process.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 319b741..b75bccb 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -751,3 +751,54 @@
 ##
 { 'command': 'query-named-block-nodes', 'returns': [ 'BlockDeviceInfo' ] }
 
+##
+# @drive-mirror
+#
+# Start mirroring a block device's writes to a new destination.
+#
+# @device:  the name of the device whose writes should be mirrored.
+#
+# @target: the target of the new image. If the file exists, or if it
+#  is a device, the existing file/device will be used as the new
+#  destination.  If it does not exist, a new file will be created.
+#
+# @format: #optional the format of the new destination, default is to
+#  probe if @mode is 'existing', else the format of the source
+#
+# @mode: #optional whether and how QEMU should create a new image, default is
+#'absolute-paths'.
+#
+# @speed:  #optional the maximum speed, in bytes per second
+#
+# @sync: what parts of the disk image should be copied to the destination
+#(all the disk, only the sectors allocated in the topmost image, or
+#only new I/O).
+#
+# @granularity: #optional granularity of the dirty bitmap, default is 64K
+#   if the image format doesn't have clusters, 4K if the clusters
+#   are smaller than that, else the cluster size.  Must be a
+#   power of 2 between 512 and 64M (since 1.4).
+#
+# @buf-size: #optional maximum amount of data in flight from source to
+#target (since 1.4).
+#
+# @on-source-error: #optional the action to take on an error on the source,
+#   default 'report'.  'stop' and 'enospc' can only be used
+#   if the block device supports io-status (see BlockInfo).
+#
+# @on-target-error: #optional the action to take on an error on the target,
+#   default 'report' (no limitations, since this applies to
+#   a different block device than @device).
+#
+# Returns: nothing on success
+#  If @device is not a valid block device, DeviceNotFound
+#
+# Since 1.3
+##
+{ 'command': 'drive-mirror',
+  'data': { 'device': 'str', 'target': 'str', '*format': 'str',
+'sync': 'MirrorSyncMode', '*mode': 'NewImageMode',
+'*speed': 'int', '*granularity

[Qemu-devel] [PATCH v1 29/72] qapi: Extract NewImageMode definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 17 -
 qapi/block-core.json | 17 +
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 88b12d4..a317aa2 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1201,23 +1201,6 @@
 { 'command': 'balloon', 'data': {'value': 'int'} }
 
 ##
-# @NewImageMode
-#
-# An enumeration that tells QEMU how to set the backing file path in
-# a new image file.
-#
-# @existing: QEMU should look for an existing image file.
-#
-# @absolute-paths: QEMU should create a new image with absolute paths
-# for the backing file. If there is no backing file available, the new
-# image will not be backed either.
-#
-# Since: 1.1
-##
-{ 'enum': 'NewImageMode',
-  'data': [ 'existing', 'absolute-paths' ] }
-
-##
 # @BlockdevSnapshot
 #
 # Either @device or @node-name must be set but not both.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index a23c1ef..c5bdfb9 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -582,3 +582,20 @@
'*node-name': 'str',
'size': 'int' }}
 
+##
+# @NewImageMode
+#
+# An enumeration that tells QEMU how to set the backing file path in
+# a new image file.
+#
+# @existing: QEMU should look for an existing image file.
+#
+# @absolute-paths: QEMU should create a new image with absolute paths
+# for the backing file. If there is no backing file available, the new
+# image will not be backed either.
+#
+# Since: 1.1
+##
+{ 'enum': 'NewImageMode',
+  'data': [ 'existing', 'absolute-paths' ] }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 65/72] qapi: Extract BiosAtaTranslation definition into qapi/block.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 34 --
 qapi/block.json  | 34 ++
 2 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index c888d23..7f928e4 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -32,40 +32,6 @@
 { 'enum': 'LostTickPolicy',
   'data': ['discard', 'delay', 'merge', 'slew' ] }
 
-##
-# BiosAtaTranslation:
-#
-# Policy that BIOS should use to interpret cylinder/head/sector
-# addresses.  Note that Bochs BIOS and SeaBIOS will not actually
-# translate logical CHS to physical; instead, they will use logical
-# block addressing.
-#
-# @auto: If cylinder/heads/sizes are passed, choose between none and LBA
-#depending on the size of the disk.  If they are not passed,
-#choose none if QEMU can guess that the disk had 16 or fewer
-#heads, large if QEMU can guess that the disk had 131072 or
-#fewer tracks across all heads (i.e. cylinders*heads<131072),
-#otherwise LBA.
-#
-# @none: The physical disk geometry is equal to the logical geometry.
-#
-# @lba: Assume 63 sectors per track and one of 16, 32, 64, 128 or 255
-#   heads (if fewer than 255 are enough to cover the whole disk
-#   with 1024 cylinders/head).  The number of cylinders/head is
-#   then computed based on the number of sectors and heads.
-#
-# @large: The number of cylinders per head is scaled down to 1024
-# by correspondingly scaling up the number of heads.
-#
-# @rechs: Same as @large, but first convert a 16-head geometry to
-# 15-head, by proportionally scaling up the number of
-# cylinders/head.
-#
-# Since: 2.0
-##
-{ 'enum': 'BiosAtaTranslation',
-  'data': ['auto', 'none', 'lba', 'large', 'rechs']}
-
 # @add_client
 #
 # Allow client connections for VNC, Spice and socket based
diff --git a/qapi/block.json b/qapi/block.json
index e2b882f..f89ab8e 100644
--- a/qapi/block.json
+++ b/qapi/block.json
@@ -5,3 +5,37 @@
 # QAPI block core definitions
 { 'include': 'block-core.json' }
 
+##
+# BiosAtaTranslation:
+#
+# Policy that BIOS should use to interpret cylinder/head/sector
+# addresses.  Note that Bochs BIOS and SeaBIOS will not actually
+# translate logical CHS to physical; instead, they will use logical
+# block addressing.
+#
+# @auto: If cylinder/heads/sizes are passed, choose between none and LBA
+#depending on the size of the disk.  If they are not passed,
+#choose none if QEMU can guess that the disk had 16 or fewer
+#heads, large if QEMU can guess that the disk had 131072 or
+#fewer tracks across all heads (i.e. cylinders*heads<131072),
+#otherwise LBA.
+#
+# @none: The physical disk geometry is equal to the logical geometry.
+#
+# @lba: Assume 63 sectors per track and one of 16, 32, 64, 128 or 255
+#   heads (if fewer than 255 are enough to cover the whole disk
+#   with 1024 cylinders/head).  The number of cylinders/head is
+#   then computed based on the number of sectors and heads.
+#
+# @large: The number of cylinders per head is scaled down to 1024
+# by correspondingly scaling up the number of heads.
+#
+# @rechs: Same as @large, but first convert a 16-head geometry to
+# 15-head, by proportionally scaling up the number of
+# cylinders/head.
+#
+# Since: 2.0
+##
+{ 'enum': 'BiosAtaTranslation',
+  'data': ['auto', 'none', 'lba', 'large', 'rechs']}
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 67/72] qapi: Extract blockdev-snapshot-internal-sync definition into qapi/block.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 20 
 qapi/block.json  | 20 
 2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index eee4508..8a6e192 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1213,26 +1213,6 @@
   'data': { 'actions': [ 'TransactionAction' ] } }
 
 ##
-# @blockdev-snapshot-internal-sync
-#
-# Synchronously take an internal snapshot of a block device, when the format
-# of the image used supports it.
-#
-# For the arguments, see the documentation of BlockdevSnapshotInternal.
-#
-# Returns: nothing on success
-#  If @device is not a valid block device, DeviceNotFound
-#  If any snapshot matching @name exists, or @name is empty,
-#  GenericError
-#  If the format of the image used does not support it,
-#  BlockFormatFeatureNotSupported
-#
-# Since 1.7
-##
-{ 'command': 'blockdev-snapshot-internal-sync',
-  'data': 'BlockdevSnapshotInternal' }
-
-##
 # @blockdev-snapshot-delete-internal-sync
 #
 # Synchronously delete an internal snapshot of a block device, when the format
diff --git a/qapi/block.json b/qapi/block.json
index ae4c0ad..830751c 100644
--- a/qapi/block.json
+++ b/qapi/block.json
@@ -55,3 +55,23 @@
 { 'type': 'BlockdevSnapshotInternal',
   'data': { 'device': 'str', 'name': 'str' } }
 
+##
+# @blockdev-snapshot-internal-sync
+#
+# Synchronously take an internal snapshot of a block device, when the format
+# of the image used supports it.
+#
+# For the arguments, see the documentation of BlockdevSnapshotInternal.
+#
+# Returns: nothing on success
+#  If @device is not a valid block device, DeviceNotFound
+#  If any snapshot matching @name exists, or @name is empty,
+#  GenericError
+#  If the format of the image used does not support it,
+#  BlockFormatFeatureNotSupported
+#
+# Since 1.7
+##
+{ 'command': 'blockdev-snapshot-internal-sync',
+  'data': 'BlockdevSnapshotInternal' }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 66/72] qapi: Extract BlockdevSnapshotInternal definition into qapi/block.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 16 
 qapi/block.json  | 16 
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 7f928e4..eee4508 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1167,22 +1167,6 @@
 { 'command': 'balloon', 'data': {'value': 'int'} }
 
 ##
-# @BlockdevSnapshotInternal
-#
-# @device: the name of the device to generate the snapshot from
-#
-# @name: the name of the internal snapshot to be created
-#
-# Notes: In transaction, if @name is empty, or any snapshot matching @name
-#exists, the operation will fail. Only some image formats support it,
-#for example, qcow2, rbd, and sheepdog.
-#
-# Since: 1.7
-##
-{ 'type': 'BlockdevSnapshotInternal',
-  'data': { 'device': 'str', 'name': 'str' } }
-
-##
 # @Abort
 #
 # This action can be used to test transaction failure.
diff --git a/qapi/block.json b/qapi/block.json
index f89ab8e..ae4c0ad 100644
--- a/qapi/block.json
+++ b/qapi/block.json
@@ -39,3 +39,19 @@
 { 'enum': 'BiosAtaTranslation',
   'data': ['auto', 'none', 'lba', 'large', 'rechs']}
 
+##
+# @BlockdevSnapshotInternal
+#
+# @device: the name of the device to generate the snapshot from
+#
+# @name: the name of the internal snapshot to be created
+#
+# Notes: In transaction, if @name is empty, or any snapshot matching @name
+#exists, the operation will fail. Only some image formats support it,
+#for example, qcow2, rbd, and sheepdog.
+#
+# Since: 1.7
+##
+{ 'type': 'BlockdevSnapshotInternal',
+  'data': { 'device': 'str', 'name': 'str' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 57/72] qapi: Extract BlkdebugInjectErrorOptions definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 32 
 qapi/block-core.json | 32 
 2 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index d1437a6..d2a25c4 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3162,38 +3162,6 @@
   'returns': ['RxFilterInfo'] }
 
 ##
-# @BlkdebugInjectErrorOptions
-#
-# Describes a single error injection for blkdebug.
-#
-# @event:   trigger event
-#
-# @state:   #optional the state identifier blkdebug needs to be in to
-#   actually trigger the event; defaults to "any"
-#
-# @errno:   #optional error identifier (errno) to be returned; defaults to
-#   EIO
-#
-# @sector:  #optional specifies the sector index which has to be affected
-#   in order to actually trigger the event; defaults to "any
-#   sector"
-#
-# @once:#optional disables further events after this one has been
-#   triggered; defaults to false
-#
-# @immediately: #optional fail immediately; defaults to false
-#
-# Since: 2.0
-##
-{ 'type': 'BlkdebugInjectErrorOptions',
-  'data': { 'event': 'BlkdebugEvent',
-'*state': 'int',
-'*errno': 'int',
-'*sector': 'int',
-'*once': 'bool',
-'*immediately': 'bool' } }
-
-##
 # @BlkdebugSetStateOptions
 #
 # Describes a single state-change event for blkdebug.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index c67d497..5aba01d 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1259,3 +1259,35 @@
 'cluster_alloc_bytes', 'cluster_free', 'flush_to_os',
 'flush_to_disk' ] }
 
+##
+# @BlkdebugInjectErrorOptions
+#
+# Describes a single error injection for blkdebug.
+#
+# @event:   trigger event
+#
+# @state:   #optional the state identifier blkdebug needs to be in to
+#   actually trigger the event; defaults to "any"
+#
+# @errno:   #optional error identifier (errno) to be returned; defaults to
+#   EIO
+#
+# @sector:  #optional specifies the sector index which has to be affected
+#   in order to actually trigger the event; defaults to "any
+#   sector"
+#
+# @once:#optional disables further events after this one has been
+#   triggered; defaults to false
+#
+# @immediately: #optional fail immediately; defaults to false
+#
+# Since: 2.0
+##
+{ 'type': 'BlkdebugInjectErrorOptions',
+  'data': { 'event': 'BlkdebugEvent',
+'*state': 'int',
+'*errno': 'int',
+'*sector': 'int',
+'*once': 'bool',
+'*immediately': 'bool' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 52/72] qapi: Extract BlockdevOptionsVVFAT definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 17 -
 qapi/block-core.json | 17 +
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 9957054..547d90a 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3162,23 +3162,6 @@
   'returns': ['RxFilterInfo'] }
 
 ##
-# @BlockdevOptionsVVFAT
-#
-# Driver specific block device options for the vvfat protocol.
-#
-# @dir: directory to be exported as FAT image
-# @fat-type:#optional FAT type: 12, 16 or 32
-# @floppy:  #optional whether to export a floppy image (true) or
-#   partitioned hard disk (false; default)
-# @rw:  #optional whether to allow write operations (default: false)
-#
-# Since: 1.7
-##
-{ 'type': 'BlockdevOptionsVVFAT',
-  'data': { 'dir': 'str', '*fat-type': 'int', '*floppy': 'bool',
-'*rw': 'bool' } }
-
-##
 # @BlockdevOptionsGenericFormat
 #
 # Driver specific block device options for image format that have no option
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 262d95c..6e2c443 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1165,3 +1165,20 @@
 { 'type': 'BlockdevOptionsFile',
   'data': { 'filename': 'str' } }
 
+##
+# @BlockdevOptionsVVFAT
+#
+# Driver specific block device options for the vvfat protocol.
+#
+# @dir: directory to be exported as FAT image
+# @fat-type:#optional FAT type: 12, 16 or 32
+# @floppy:  #optional whether to export a floppy image (true) or
+#   partitioned hard disk (false; default)
+# @rw:  #optional whether to allow write operations (default: false)
+#
+# Since: 1.7
+##
+{ 'type': 'BlockdevOptionsVVFAT',
+  'data': { 'dir': 'str', '*fat-type': 'int', '*floppy': 'bool',
+'*rw': 'bool' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 56/72] qapi: Extract BlkdebugEvent definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 19 ---
 qapi/block-core.json | 19 +++
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 63a0de3..d1437a6 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3162,25 +3162,6 @@
   'returns': ['RxFilterInfo'] }
 
 ##
-# @BlkdebugEvent
-#
-# Trigger events supported by blkdebug.
-##
-{ 'enum': 'BlkdebugEvent',
-  'data': [ 'l1_update', 'l1_grow.alloc_table', 'l1_grow.write_table',
-'l1_grow.activate_table', 'l2_load', 'l2_update',
-'l2_update_compressed', 'l2_alloc.cow_read', 'l2_alloc.write',
-'read_aio', 'read_backing_aio', 'read_compressed', 'write_aio',
-'write_compressed', 'vmstate_load', 'vmstate_save', 'cow_read',
-'cow_write', 'reftable_load', 'reftable_grow', 'reftable_update',
-'refblock_load', 'refblock_update', 'refblock_update_part',
-'refblock_alloc', 'refblock_alloc.hookup', 'refblock_alloc.write',
-'refblock_alloc.write_blocks', 'refblock_alloc.write_table',
-'refblock_alloc.switch_table', 'cluster_alloc',
-'cluster_alloc_bytes', 'cluster_free', 'flush_to_os',
-'flush_to_disk' ] }
-
-##
 # @BlkdebugInjectErrorOptions
 #
 # Describes a single error injection for blkdebug.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index fcb2625..c67d497 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1240,3 +1240,22 @@
 '*pass-discard-snapshot': 'bool',
 '*pass-discard-other': 'bool' } }
 
+##
+# @BlkdebugEvent
+#
+# Trigger events supported by blkdebug.
+##
+{ 'enum': 'BlkdebugEvent',
+  'data': [ 'l1_update', 'l1_grow.alloc_table', 'l1_grow.write_table',
+'l1_grow.activate_table', 'l2_load', 'l2_update',
+'l2_update_compressed', 'l2_alloc.cow_read', 'l2_alloc.write',
+'read_aio', 'read_backing_aio', 'read_compressed', 'write_aio',
+'write_compressed', 'vmstate_load', 'vmstate_save', 'cow_read',
+'cow_write', 'reftable_load', 'reftable_grow', 'reftable_update',
+'refblock_load', 'refblock_update', 'refblock_update_part',
+'refblock_alloc', 'refblock_alloc.hookup', 'refblock_alloc.write',
+'refblock_alloc.write_blocks', 'refblock_alloc.write_table',
+'refblock_alloc.switch_table', 'cluster_alloc',
+'cluster_alloc_bytes', 'cluster_free', 'flush_to_os',
+'flush_to_disk' ] }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 07/72] qapi: Extract SnapshotInfo definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 26 --
 qapi/block-core.json | 25 +
 2 files changed, 25 insertions(+), 26 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 1ed5926..50cb25a 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -184,32 +184,6 @@
 'guest-panicked' ] }
 
 ##
-# @SnapshotInfo
-#
-# @id: unique snapshot id
-#
-# @name: user chosen name
-#
-# @vm-state-size: size of the VM state
-#
-# @date-sec: UTC date of the snapshot in seconds
-#
-# @date-nsec: fractional part in nano seconds to be used with date-sec
-#
-# @vm-clock-sec: VM clock relative to boot in seconds
-#
-# @vm-clock-nsec: fractional part in nano seconds to be used with vm-clock-sec
-#
-# Since: 1.3
-#
-##
-
-{ 'type': 'SnapshotInfo',
-  'data': { 'id': 'str', 'name': 'str', 'vm-state-size': 'int',
-'date-sec': 'int', 'date-nsec': 'int',
-'vm-clock-sec': 'int', 'vm-clock-nsec': 'int' } }
-
-##
 # @ImageInfoSpecificQCow2:
 #
 # @compat: compatibility level
diff --git a/qapi/block-core.json b/qapi/block-core.json
index fa48e63..f4948a4 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -5,4 +5,29 @@
 # QAPI common definitions
 { 'include': 'common.json' }
 
+##
+# @SnapshotInfo
+#
+# @id: unique snapshot id
+#
+# @name: user chosen name
+#
+# @vm-state-size: size of the VM state
+#
+# @date-sec: UTC date of the snapshot in seconds
+#
+# @date-nsec: fractional part in nano seconds to be used with date-sec
+#
+# @vm-clock-sec: VM clock relative to boot in seconds
+#
+# @vm-clock-nsec: fractional part in nano seconds to be used with vm-clock-sec
+#
+# Since: 1.3
+#
+##
+
+{ 'type': 'SnapshotInfo',
+  'data': { 'id': 'str', 'name': 'str', 'vm-state-size': 'int',
+'date-sec': 'int', 'date-nsec': 'int',
+'vm-clock-sec': 'int', 'vm-clock-nsec': 'int' } }
 
-- 
1.9.1




[Qemu-devel] [PATCH v1 54/72] qapi: Extract BlockdevOptionsGenericCOWFormat definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 17 -
 qapi/block-core.json | 17 +
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index e96b746..ad0f1ae 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3162,23 +3162,6 @@
   'returns': ['RxFilterInfo'] }
 
 ##
-# @BlockdevOptionsGenericCOWFormat
-#
-# Driver specific block device options for image format that have no option
-# besides their data source and an optional backing file.
-#
-# @backing: #optional reference to or definition of the backing file block
-#   device (if missing, taken from the image file content). It is
-#   allowed to pass an empty string here in order to disable the
-#   default backing file.
-#
-# Since: 1.7
-##
-{ 'type': 'BlockdevOptionsGenericCOWFormat',
-  'base': 'BlockdevOptionsGenericFormat',
-  'data': { '*backing': 'BlockdevRef' } }
-
-##
 # @BlockdevOptionsQcow2
 #
 # Driver specific block device options for qcow2.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 3ce836c..b762e67 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1195,3 +1195,20 @@
 { 'type': 'BlockdevOptionsGenericFormat',
   'data': { 'file': 'BlockdevRef' } }
 
+##
+# @BlockdevOptionsGenericCOWFormat
+#
+# Driver specific block device options for image format that have no option
+# besides their data source and an optional backing file.
+#
+# @backing: #optional reference to or definition of the backing file block
+#   device (if missing, taken from the image file content). It is
+#   allowed to pass an empty string here in order to disable the
+#   default backing file.
+#
+# Since: 1.7
+##
+{ 'type': 'BlockdevOptionsGenericCOWFormat',
+  'base': 'BlockdevOptionsGenericFormat',
+  'data': { '*backing': 'BlockdevRef' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 15/72] qapi: Extract BlockDeviceMapEntry definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 29 -
 qapi/block-core.json | 29 +
 2 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 408602b..7047209 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -664,35 +664,6 @@
 { 'command': 'query-iothreads', 'returns': ['IOThreadInfo'] }
 
 ##
-# @BlockDeviceMapEntry:
-#
-# Entry in the metadata map of the device (returned by "qemu-img map")
-#
-# @start: Offset in the image of the first byte described by this entry
-# (in bytes)
-#
-# @length: Length of the range described by this entry (in bytes)
-#
-# @depth: Number of layers (0 = top image, 1 = top image's backing file, etc.)
-# before reaching one for which the range is allocated.  The value is
-# in the range 0 to the depth of the image chain - 1.
-#
-# @zero: the sectors in this range read as zeros
-#
-# @data: reading the image will actually read data from a file (in particular,
-#if @offset is present this means that the sectors are not simply
-#preallocated, but contain actual data in raw format)
-#
-# @offset: if present, the image file stores the data for this range in
-#  raw format at the given offset.
-#
-# Since 1.7
-##
-{ 'type': 'BlockDeviceMapEntry',
-  'data': { 'start': 'int', 'length': 'int', 'depth': 'int', 'zero': 'bool',
-'data': 'bool', '*offset': 'int' } }
-
-##
 # @BlockDirtyInfo:
 #
 # Block dirty bitmap information.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index d355daa..950defd 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -265,3 +265,32 @@
 ##
 { 'enum': 'BlockDeviceIoStatus', 'data': [ 'ok', 'failed', 'nospace' ] }
 
+##
+# @BlockDeviceMapEntry:
+#
+# Entry in the metadata map of the device (returned by "qemu-img map")
+#
+# @start: Offset in the image of the first byte described by this entry
+# (in bytes)
+#
+# @length: Length of the range described by this entry (in bytes)
+#
+# @depth: Number of layers (0 = top image, 1 = top image's backing file, etc.)
+# before reaching one for which the range is allocated.  The value is
+# in the range 0 to the depth of the image chain - 1.
+#
+# @zero: the sectors in this range read as zeros
+#
+# @data: reading the image will actually read data from a file (in particular,
+#if @offset is present this means that the sectors are not simply
+#preallocated, but contain actual data in raw format)
+#
+# @offset: if present, the image file stores the data for this range in
+#  raw format at the given offset.
+#
+# Since 1.7
+##
+{ 'type': 'BlockDeviceMapEntry',
+  'data': { 'start': 'int', 'length': 'int', 'depth': 'int', 'zero': 'bool',
+'data': 'bool', '*offset': 'int' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 12/72] qapi: Extract ImageCheck definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 50 --
 qapi/block-core.json | 50 ++
 2 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index fcccfe6..c6e561c 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -184,56 +184,6 @@
 'guest-panicked' ] }
 
 ##
-# @ImageCheck:
-#
-# Information about a QEMU image file check
-#
-# @filename: name of the image file checked
-#
-# @format: format of the image file checked
-#
-# @check-errors: number of unexpected errors occurred during check
-#
-# @image-end-offset: #optional offset (in bytes) where the image ends, this
-#field is present if the driver for the image format
-#supports it
-#
-# @corruptions: #optional number of corruptions found during the check if any
-#
-# @leaks: #optional number of leaks found during the check if any
-#
-# @corruptions-fixed: #optional number of corruptions fixed during the check
-# if any
-#
-# @leaks-fixed: #optional number of leaks fixed during the check if any
-#
-# @total-clusters: #optional total number of clusters, this field is present
-#  if the driver for the image format supports it
-#
-# @allocated-clusters: #optional total number of allocated clusters, this
-#  field is present if the driver for the image format
-#  supports it
-#
-# @fragmented-clusters: #optional total number of fragmented clusters, this
-#   field is present if the driver for the image format
-#   supports it
-#
-# @compressed-clusters: #optional total number of compressed clusters, this
-#   field is present if the driver for the image format
-#   supports it
-#
-# Since: 1.4
-#
-##
-
-{ 'type': 'ImageCheck',
-  'data': {'filename': 'str', 'format': 'str', 'check-errors': 'int',
-   '*image-end-offset': 'int', '*corruptions': 'int', '*leaks': 'int',
-   '*corruptions-fixed': 'int', '*leaks-fixed': 'int',
-   '*total-clusters': 'int', '*allocated-clusters': 'int',
-   '*fragmented-clusters': 'int', '*compressed-clusters': 'int' } }
-
-##
 # @StatusInfo:
 #
 # Information about VCPU run state
diff --git a/qapi/block-core.json b/qapi/block-core.json
index bb0f0bf..8313403 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -128,3 +128,53 @@
'*backing-image': 'ImageInfo',
'*format-specific': 'ImageInfoSpecific' } }
 
+##
+# @ImageCheck:
+#
+# Information about a QEMU image file check
+#
+# @filename: name of the image file checked
+#
+# @format: format of the image file checked
+#
+# @check-errors: number of unexpected errors occurred during check
+#
+# @image-end-offset: #optional offset (in bytes) where the image ends, this
+#field is present if the driver for the image format
+#supports it
+#
+# @corruptions: #optional number of corruptions found during the check if any
+#
+# @leaks: #optional number of leaks found during the check if any
+#
+# @corruptions-fixed: #optional number of corruptions fixed during the check
+# if any
+#
+# @leaks-fixed: #optional number of leaks fixed during the check if any
+#
+# @total-clusters: #optional total number of clusters, this field is present
+#  if the driver for the image format supports it
+#
+# @allocated-clusters: #optional total number of allocated clusters, this
+#  field is present if the driver for the image format
+#  supports it
+#
+# @fragmented-clusters: #optional total number of fragmented clusters, this
+#   field is present if the driver for the image format
+#   supports it
+#
+# @compressed-clusters: #optional total number of compressed clusters, this
+#   field is present if the driver for the image format
+#   supports it
+#
+# Since: 1.4
+#
+##
+
+{ 'type': 'ImageCheck',
+  'data': {'filename': 'str', 'format': 'str', 'check-errors': 'int',
+   '*image-end-offset': 'int', '*corruptions': 'int', '*leaks': 'int',
+   '*corruptions-fixed': 'int', '*leaks-fixed': 'int',
+   '*total-clusters': 'int', '*allocated-clusters': 'int',
+   '*fragmented-clusters': 'int', '*compressed-clusters': 'int' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 00/72] Extract qapi commons and block definitions

2014-05-31 Thread Benoît Canet
This hudge chainsawing series sit on top of my quorum maintenance series.

It extract commons definition and block definition into separate files.

-qapi/common.json contains some definition required by all qapi modules
-qapi/block-core.json contains core qapi block definition usable without the 
emulation
code.
-qapi/block.json is a superset of the previous usable with emulation

Transaction where left appart because they relies on internal snapshot and hence
cannot be included in block-core.json for now.

Best regards

Benoît

Benoît Canet (72):
  qapi: Extract ErrorClass definition in qapi/common.json
  qapi: Extract VersionInfo definition in qapi/common.json
  qapi: Extract query-version definition in qapi/common.json
  qapi: Extract CommandInfo definition in qapi/common.json
  qapi: Extract query-commands definition into qapi/common.json
  qapi: create two block related json modules
  qapi: Extract SnapshotInfo definition into qapi/block-core.json
  qapi: Extract ImageInfoSpecificQCow2 definition into
qapi/block-core.json
  qapi: Extract ImageInfoSpecificQCow2 definition into
qapi/block-core.json
  qapi: Extract ImageInfoSpecific definition into qapi/block-core.json
  qapi: Extract ImageInfo definition into qapi/block-core.json
  qapi: Extract ImageCheck definition into qapi/block-core.json
  qapi: Extract BlockDeviceInfo definition into qapi/block-core.json
  qapi: Extract BlockDeviceIoStatus definition into qapi/block-core.json
  qapi: Extract BlockDeviceMapEntry definition into qapi/block-core.json
  qapi: Extract BlockDirtyInfo definition into qapi/block-core.json
  qapi: Extract BlockInfo definition into qapi/block-core.json
  qapi: Extract query-block definition into qapi/block-core.json
  qapi: Extract BlockDeviceStats definition into qapi/block-core.json
  qapi: Extract BlockStats definition into qapi/block-core.json
  qapi: Extract query-blockstats definition into qapi/block-core.json
  qapi: Extract BlockdevOnError definition into qapi/block-core.json
  qapi: Extract MirrorSyncMode definition into qapi/block-core.json
  qapi: Extract BlockJobType definition into qapi/block-core.json
  qapi: Extract BlockJobInfo definition into qapi/block-core.json
  qapi: Extract query-block-jobs definition into qapi/block-core.json
  qapi: Extract block_passwd definition into qapi/block-core.json
  qapi: Extract block_resize definition into qapi/block-core.json
  qapi: Extract NewImageMode definition into qapi/block-core.json
  qapi: Extract BlockdevSnapshot definition into qapi/block-core.json
  qapi: Extract DriveBackup definition into qapi/block-core.json
  qapi: Extract blockdev-snapshot-sync into qapi/block-core.json
  qapi: Extract block-commit definition into qapi/block-core.json
  qapi: Extract drive-backup definition into qapi/block-core.json
  qapi: Extract query-named-block-nodes definition into
qapi/block-core.json
  qapi: Extract drive-mirror definition into qapi/block-core.json
  qapi: Extract block_set_io_throttle definition into
qapi/block-core.json
  qapi: Extract block-stream definition into qapi/block-core.json
  qapi: Extract block-job-set-speed definition into qapi/block-core.json
  qapi: Extrat block-job-cancel definition into qapi/block-core.json
  qapi: Extract block-job-pause definition into qapi/block-core.json
  qapi: Extract block-job-resume definition into qapi/block-core.json
  qapi: Extract block-job-complete definition into qapi/block-core.json
  qapi: Extract drive-mirror-replace definition into
qapi/block-core.json
  qapi: Extract BlockdevDiscardOptions definition into
qapi/block-core.json
  qapi: Extract BlockdevDetectZeroesOptions definition into
qapi/block-core.json
  qapi: Extract BlockdevAioOptions definition into qapi/block-core.json
  qapi: Extract BlockdevCacheOptions definition into
qapi/block-core.json
  qapi: Extract BlockdevDriver definition into qapi/block-core.json
  qapi: Extract BlockdevOptionsBase definition into qapi/block-core.json
  qapi: Extract BlockdevOptionsFile definition into qapi/block-core.json
  qapi: Extract BlockdevOptionsVVFAT definition into
qapi/block-core.json
  qapi: Extract BlockdevOptionsGenericFormat definition into
qapi/block-core.json
  qapi: Extract BlockdevOptionsGenericCOWFormat definition into
qapi/block-core.json
  qapi: Extract BlockdevOptionsQcow2 definition into
qapi/block-core.json
  qapi: Extract BlkdebugEvent definition into qapi/block-core.json
  qapi: Extract BlkdebugInjectErrorOptions definition into
qapi/block-core.json
  qapi: Extract BlkdebugSetStateOptions definition into
qapi/block-core.json
  qapi: Extract BlockdevOptionsBlkdebug definition into
qapi/block-core.json
  qapi: Extract BlockdevOptionsBlkverify definition into
qapi/block-core.json
  qapi: Extract BlockdevOptionsQuorum definition into
qapi/block-core.json
  qapi: Extract BlockdevOptions definition into qapi/block-core.json
  qapi: Extract BlockdevRef definition into qapi/block-core.json

[Qemu-devel] [PATCH v1 20/72] qapi: Extract BlockStats definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 22 --
 qapi/block-core.json | 22 ++
 2 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index dd2b52a..5d22e55 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -664,28 +664,6 @@
 { 'command': 'query-iothreads', 'returns': ['IOThreadInfo'] }
 
 ##
-# @BlockStats:
-#
-# Statistics of a virtual block device or a block backing device.
-#
-# @device: #optional If the stats are for a virtual block device, the name
-#  corresponding to the virtual block device.
-#
-# @stats:  A @BlockDeviceStats for the device.
-#
-# @parent: #optional This describes the file block device if it has one.
-#
-# @backing: #optional This describes the backing block device if it has one.
-#   (Since 2.0)
-#
-# Since: 0.14.0
-##
-{ 'type': 'BlockStats',
-  'data': {'*device': 'str', 'stats': 'BlockDeviceStats',
-   '*parent': 'BlockStats',
-   '*backing': 'BlockStats'} }
-
-##
 # @query-blockstats:
 #
 # Query the @BlockStats for all virtual block devices.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 81bd2bb..fddcb5f 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -391,3 +391,25 @@
'flush_total_time_ns': 'int', 'wr_total_time_ns': 'int',
'rd_total_time_ns': 'int', 'wr_highest_offset': 'int' } }
 
+##
+# @BlockStats:
+#
+# Statistics of a virtual block device or a block backing device.
+#
+# @device: #optional If the stats are for a virtual block device, the name
+#  corresponding to the virtual block device.
+#
+# @stats:  A @BlockDeviceStats for the device.
+#
+# @parent: #optional This describes the file block device if it has one.
+#
+# @backing: #optional This describes the backing block device if it has one.
+#   (Since 2.0)
+#
+# Since: 0.14.0
+##
+{ 'type': 'BlockStats',
+  'data': {'*device': 'str', 'stats': 'BlockDeviceStats',
+   '*parent': 'BlockStats',
+   '*backing': 'BlockStats'} }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 53/72] qapi: Extract BlockdevOptionsGenericFormat definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 13 -
 qapi/block-core.json | 13 +
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 547d90a..e96b746 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3162,19 +3162,6 @@
   'returns': ['RxFilterInfo'] }
 
 ##
-# @BlockdevOptionsGenericFormat
-#
-# Driver specific block device options for image format that have no option
-# besides their data source.
-#
-# @file:reference to or definition of the data source block device
-#
-# Since: 1.7
-##
-{ 'type': 'BlockdevOptionsGenericFormat',
-  'data': { 'file': 'BlockdevRef' } }
-
-##
 # @BlockdevOptionsGenericCOWFormat
 #
 # Driver specific block device options for image format that have no option
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 6e2c443..3ce836c 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1182,3 +1182,16 @@
   'data': { 'dir': 'str', '*fat-type': 'int', '*floppy': 'bool',
 '*rw': 'bool' } }
 
+##
+# @BlockdevOptionsGenericFormat
+#
+# Driver specific block device options for image format that have no option
+# besides their data source.
+#
+# @file:reference to or definition of the data source block device
+#
+# Since: 1.7
+##
+{ 'type': 'BlockdevOptionsGenericFormat',
+  'data': { 'file': 'BlockdevRef' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 41/72] qapi: Extract block-job-pause definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 23 ---
 qapi/block-core.json | 23 +++
 2 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 75d76f9..17d92df 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1621,29 +1621,6 @@
   'data': {'device': 'str', 'target': 'str', '*arg': 'str'} }
 
 ##
-# @block-job-pause:
-#
-# Pause an active background block operation.
-#
-# This command returns immediately after marking the active background block
-# operation for pausing.  It is an error to call this command if no
-# operation is in progress.  Pausing an already paused job has no cumulative
-# effect; a single block-job-resume command will resume the job.
-#
-# The operation will pause as soon as possible.  No event is emitted when
-# the operation is actually paused.  Cancelling a paused job automatically
-# resumes it.
-#
-# @device: the device name
-#
-# Returns: Nothing on success
-#  If no background operation is active on this device, DeviceNotActive
-#
-# Since: 1.3
-##
-{ 'command': 'block-job-pause', 'data': { 'device': 'str' } }
-
-##
 # @block-job-resume:
 #
 # Resume an active background block operation.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 6a3de86..51c941a 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -938,3 +938,26 @@
 ##
 { 'command': 'block-job-cancel', 'data': { 'device': 'str', '*force': 'bool' } 
}
 
+##
+# @block-job-pause:
+#
+# Pause an active background block operation.
+#
+# This command returns immediately after marking the active background block
+# operation for pausing.  It is an error to call this command if no
+# operation is in progress.  Pausing an already paused job has no cumulative
+# effect; a single block-job-resume command will resume the job.
+#
+# The operation will pause as soon as possible.  No event is emitted when
+# the operation is actually paused.  Cancelling a paused job automatically
+# resumes it.
+#
+# @device: the device name
+#
+# Returns: Nothing on success
+#  If no background operation is active on this device, DeviceNotActive
+#
+# Since: 1.3
+##
+{ 'command': 'block-job-pause', 'data': { 'device': 'str' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 16/72] qapi: Extract BlockDirtyInfo definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 14 --
 qapi/block-core.json | 14 ++
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 7047209..1cb7d2c 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -664,20 +664,6 @@
 { 'command': 'query-iothreads', 'returns': ['IOThreadInfo'] }
 
 ##
-# @BlockDirtyInfo:
-#
-# Block dirty bitmap information.
-#
-# @count: number of dirty bytes according to the dirty bitmap
-#
-# @granularity: granularity of the dirty bitmap in bytes (since 1.4)
-#
-# Since: 1.3
-##
-{ 'type': 'BlockDirtyInfo',
-  'data': {'count': 'int', 'granularity': 'int'} }
-
-##
 # @BlockInfo:
 #
 # Block device information.  This structure describes a virtual device and
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 950defd..9f1995d 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -294,3 +294,17 @@
   'data': { 'start': 'int', 'length': 'int', 'depth': 'int', 'zero': 'bool',
 'data': 'bool', '*offset': 'int' } }
 
+##
+# @BlockDirtyInfo:
+#
+# Block dirty bitmap information.
+#
+# @count: number of dirty bytes according to the dirty bitmap
+#
+# @granularity: granularity of the dirty bitmap in bytes (since 1.4)
+#
+# Since: 1.3
+##
+{ 'type': 'BlockDirtyInfo',
+  'data': {'count': 'int', 'granularity': 'int'} }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 49/72] qapi: Extract BlockdevDriver definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 15 ---
 qapi/block-core.json | 15 +++
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index b046fd8..8162c9a 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3162,21 +3162,6 @@
   'returns': ['RxFilterInfo'] }
 
 ##
-# @BlockdevDriver
-#
-# Drivers that are supported in block device operations.
-#
-# @host_device, @host_cdrom, @host_floppy: Since 2.1
-#
-# Since: 2.0
-##
-{ 'enum': 'BlockdevDriver',
-  'data': [ 'file', 'host_device', 'host_cdrom', 'host_floppy',
-'http', 'https', 'ftp', 'ftps', 'tftp', 'vvfat', 'blkdebug',
-'blkverify', 'bochs', 'cloop', 'cow', 'dmg', 'parallels', 'qcow',
-'qcow2', 'qed', 'raw', 'vdi', 'vhdx', 'vmdk', 'vpc', 'quorum' ] }
-
-##
 # @BlockdevOptionsBase
 #
 # Options that are available for all block devices, independent of the block
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 104d876..95362a8 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1100,3 +1100,18 @@
 '*direct': 'bool',
 '*no-flush': 'bool' } }
 
+##
+# @BlockdevDriver
+#
+# Drivers that are supported in block device operations.
+#
+# @host_device, @host_cdrom, @host_floppy: Since 2.1
+#
+# Since: 2.0
+##
+{ 'enum': 'BlockdevDriver',
+  'data': [ 'file', 'host_device', 'host_cdrom', 'host_floppy',
+'http', 'https', 'ftp', 'ftps', 'tftp', 'vvfat', 'blkdebug',
+'blkverify', 'bochs', 'cloop', 'cow', 'dmg', 'parallels', 'qcow',
+'qcow2', 'qed', 'raw', 'vdi', 'vhdx', 'vmdk', 'vpc', 'quorum' ] }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 32/72] qapi: Extract blockdev-snapshot-sync into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 15 ---
 qapi/block-core.json | 15 +++
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index a03125f..09b864f 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1263,21 +1263,6 @@
   'data': { 'actions': [ 'TransactionAction' ] } }
 
 ##
-# @blockdev-snapshot-sync
-#
-# Generates a synchronous snapshot of a block device.
-#
-# For the arguments, see the documentation of BlockdevSnapshot.
-#
-# Returns: nothing on success
-#  If @device is not a valid block device, DeviceNotFound
-#
-# Since 0.14.0
-##
-{ 'command': 'blockdev-snapshot-sync',
-  'data': 'BlockdevSnapshot' }
-
-##
 # @blockdev-snapshot-internal-sync
 #
 # Synchronously take an internal snapshot of a block device, when the format
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 992fa7b..1f482f1 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -664,3 +664,18 @@
 '*on-source-error': 'BlockdevOnError',
 '*on-target-error': 'BlockdevOnError' } }
 
+##
+# @blockdev-snapshot-sync
+#
+# Generates a synchronous snapshot of a block device.
+#
+# For the arguments, see the documentation of BlockdevSnapshot.
+#
+# Returns: nothing on success
+#  If @device is not a valid block device, DeviceNotFound
+#
+# Since 0.14.0
+##
+{ 'command': 'blockdev-snapshot-sync',
+  'data': 'BlockdevSnapshot' }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 19/72] qapi: Extract BlockDeviceStats definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 36 
 qapi/block-core.json | 36 
 2 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 31102cf..dd2b52a 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -664,42 +664,6 @@
 { 'command': 'query-iothreads', 'returns': ['IOThreadInfo'] }
 
 ##
-# @BlockDeviceStats:
-#
-# Statistics of a virtual block device or a block backing device.
-#
-# @rd_bytes:  The number of bytes read by the device.
-#
-# @wr_bytes:  The number of bytes written by the device.
-#
-# @rd_operations: The number of read operations performed by the device.
-#
-# @wr_operations: The number of write operations performed by the device.
-#
-# @flush_operations: The number of cache flush operations performed by the
-#device (since 0.15.0)
-#
-# @flush_total_time_ns: Total time spend on cache flushes in nano-seconds
-#   (since 0.15.0).
-#
-# @wr_total_time_ns: Total time spend on writes in nano-seconds (since 0.15.0).
-#
-# @rd_total_time_ns: Total_time_spend on reads in nano-seconds (since 0.15.0).
-#
-# @wr_highest_offset: The offset after the greatest byte written to the
-# device.  The intended use of this information is for
-# growable sparse files (like qcow2) that are used on top
-# of a physical device.
-#
-# Since: 0.14.0
-##
-{ 'type': 'BlockDeviceStats',
-  'data': {'rd_bytes': 'int', 'wr_bytes': 'int', 'rd_operations': 'int',
-   'wr_operations': 'int', 'flush_operations': 'int',
-   'flush_total_time_ns': 'int', 'wr_total_time_ns': 'int',
-   'rd_total_time_ns': 'int', 'wr_highest_offset': 'int' } }
-
-##
 # @BlockStats:
 #
 # Statistics of a virtual block device or a block backing device.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 7be8ffe..81bd2bb 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -355,3 +355,39 @@
 ##
 { 'command': 'query-block', 'returns': ['BlockInfo'] }
 
+##
+# @BlockDeviceStats:
+#
+# Statistics of a virtual block device or a block backing device.
+#
+# @rd_bytes:  The number of bytes read by the device.
+#
+# @wr_bytes:  The number of bytes written by the device.
+#
+# @rd_operations: The number of read operations performed by the device.
+#
+# @wr_operations: The number of write operations performed by the device.
+#
+# @flush_operations: The number of cache flush operations performed by the
+#device (since 0.15.0)
+#
+# @flush_total_time_ns: Total time spend on cache flushes in nano-seconds
+#   (since 0.15.0).
+#
+# @wr_total_time_ns: Total time spend on writes in nano-seconds (since 0.15.0).
+#
+# @rd_total_time_ns: Total_time_spend on reads in nano-seconds (since 0.15.0).
+#
+# @wr_highest_offset: The offset after the greatest byte written to the
+# device.  The intended use of this information is for
+# growable sparse files (like qcow2) that are used on top
+# of a physical device.
+#
+# Since: 0.14.0
+##
+{ 'type': 'BlockDeviceStats',
+  'data': {'rd_bytes': 'int', 'wr_bytes': 'int', 'rd_operations': 'int',
+   'wr_operations': 'int', 'flush_operations': 'int',
+   'flush_total_time_ns': 'int', 'wr_total_time_ns': 'int',
+   'rd_total_time_ns': 'int', 'wr_highest_offset': 'int' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 34/72] qapi: Extract drive-backup definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 18 --
 qapi/block-core.json | 18 ++
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 02958cc..79595b1 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1338,24 +1338,6 @@
   'returns': 'str' }
 
 ##
-# @drive-backup
-#
-# Start a point-in-time copy of a block device to a new destination.  The
-# status of ongoing drive-backup operations can be checked with
-# query-block-jobs where the BlockJobInfo.type field has the value 'backup'.
-# The operation can be stopped before it has completed using the
-# block-job-cancel command.
-#
-# For the arguments, see the documentation of DriveBackup.
-#
-# Returns: nothing on success
-#  If @device is not a valid block device, DeviceNotFound
-#
-# Since 1.6
-##
-{ 'command': 'drive-backup', 'data': 'DriveBackup' }
-
-##
 # @query-named-block-nodes
 #
 # Get the named block driver list
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 75fe7ce..7c4be1b 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -722,3 +722,21 @@
   'data': { 'device': 'str', '*base': 'str', 'top': 'str',
 '*speed': 'int' } }
 
+##
+# @drive-backup
+#
+# Start a point-in-time copy of a block device to a new destination.  The
+# status of ongoing drive-backup operations can be checked with
+# query-block-jobs where the BlockJobInfo.type field has the value 'backup'.
+# The operation can be stopped before it has completed using the
+# block-job-cancel command.
+#
+# For the arguments, see the documentation of DriveBackup.
+#
+# Returns: nothing on success
+#  If @device is not a valid block device, DeviceNotFound
+#
+# Since 1.6
+##
+{ 'command': 'drive-backup', 'data': 'DriveBackup' }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 30/72] qapi: Extract BlockdevSnapshot definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 23 ---
 qapi/block-core.json | 23 +++
 2 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index a317aa2..6cd9fde 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1201,29 +1201,6 @@
 { 'command': 'balloon', 'data': {'value': 'int'} }
 
 ##
-# @BlockdevSnapshot
-#
-# Either @device or @node-name must be set but not both.
-#
-# @device: #optional the name of the device to generate the snapshot from.
-#
-# @node-name: #optional graph node name to generate the snapshot from (Since 
2.0)
-#
-# @snapshot-file: the target of the new image. A new file will be created.
-#
-# @snapshot-node-name: #optional the graph node name of the new image (Since 
2.0)
-#
-# @format: #optional the format of the snapshot image, default is 'qcow2'.
-#
-# @mode: #optional whether and how QEMU should create a new image, default is
-#'absolute-paths'.
-##
-{ 'type': 'BlockdevSnapshot',
-  'data': { '*device': 'str', '*node-name': 'str',
-'snapshot-file': 'str', '*snapshot-node-name': 'str',
-'*format': 'str', '*mode': 'NewImageMode' } }
-
-##
 # @BlockdevSnapshotInternal
 #
 # @device: the name of the device to generate the snapshot from
diff --git a/qapi/block-core.json b/qapi/block-core.json
index c5bdfb9..bf546f7 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -599,3 +599,26 @@
 { 'enum': 'NewImageMode',
   'data': [ 'existing', 'absolute-paths' ] }
 
+##
+# @BlockdevSnapshot
+#
+# Either @device or @node-name must be set but not both.
+#
+# @device: #optional the name of the device to generate the snapshot from.
+#
+# @node-name: #optional graph node name to generate the snapshot from (Since 
2.0)
+#
+# @snapshot-file: the target of the new image. A new file will be created.
+#
+# @snapshot-node-name: #optional the graph node name of the new image (Since 
2.0)
+#
+# @format: #optional the format of the snapshot image, default is 'qcow2'.
+#
+# @mode: #optional whether and how QEMU should create a new image, default is
+#'absolute-paths'.
+##
+{ 'type': 'BlockdevSnapshot',
+  'data': { '*device': 'str', '*node-name': 'str',
+'snapshot-file': 'str', '*snapshot-node-name': 'str',
+'*format': 'str', '*mode': 'NewImageMode' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 04/72] qapi: Extract CommandInfo definition in qapi/common.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 11 ---
 qapi/common.json | 11 +++
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 6d0aea2..82d675e 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -523,17 +523,6 @@
   'returns': 'str' }
 
 ##
-# @CommandInfo:
-#
-# Information about a QMP command
-#
-# @name: The command name
-#
-# Since: 0.14.0
-##
-{ 'type': 'CommandInfo', 'data': {'name': 'str'} }
-
-##
 # @query-commands:
 #
 # Return a list of supported QMP commands by this server
diff --git a/qapi/common.json b/qapi/common.json
index 2f1093c..37caa5a 100644
--- a/qapi/common.json
+++ b/qapi/common.json
@@ -65,3 +65,14 @@
 ##
 { 'command': 'query-version', 'returns': 'VersionInfo' }
 
+##
+# @CommandInfo:
+#
+# Information about a QMP command
+#
+# @name: The command name
+#
+# Since: 0.14.0
+##
+{ 'type': 'CommandInfo', 'data': {'name': 'str'} }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 02/72] qapi: Extract VersionInfo definition in qapi/common.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 26 --
 qapi/common.json | 27 +++
 2 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 366a507..915bd69 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -110,32 +110,6 @@
 { 'command': 'query-name', 'returns': 'NameInfo' }
 
 ##
-# @VersionInfo:
-#
-# A description of QEMU's version.
-#
-# @qemu.major:  The major version of QEMU
-#
-# @qemu.minor:  The minor version of QEMU
-#
-# @qemu.micro:  The micro version of QEMU.  By current convention, a micro
-#   version of 50 signifies a development branch.  A micro version
-#   greater than or equal to 90 signifies a release candidate for
-#   the next minor version.  A micro version of less than 50
-#   signifies a stable release.
-#
-# @package: QEMU will always set this field to an empty string.  Downstream
-#   versions of QEMU should set this to a non-empty string.  The
-#   exact format depends on the downstream however it highly
-#   recommended that a unique name is used.
-#
-# Since: 0.14.0
-##
-{ 'type': 'VersionInfo',
-  'data': {'qemu': {'major': 'int', 'minor': 'int', 'micro': 'int'},
-   'package': 'str'} }
-
-##
 # @query-version:
 #
 # Returns the current version of QEMU.
diff --git a/qapi/common.json b/qapi/common.json
index 37f63a4..36c625b 100644
--- a/qapi/common.json
+++ b/qapi/common.json
@@ -27,3 +27,30 @@
 { 'enum': 'ErrorClass',
   'data': [ 'GenericError', 'CommandNotFound', 'DeviceEncrypted',
 'DeviceNotActive', 'DeviceNotFound', 'KVMMissingCap' ] }
+
+##
+# @VersionInfo:
+#
+# A description of QEMU's version.
+#
+# @qemu.major:  The major version of QEMU
+#
+# @qemu.minor:  The minor version of QEMU
+#
+# @qemu.micro:  The micro version of QEMU.  By current convention, a micro
+#   version of 50 signifies a development branch.  A micro version
+#   greater than or equal to 90 signifies a release candidate for
+#   the next minor version.  A micro version of less than 50
+#   signifies a stable release.
+#
+# @package: QEMU will always set this field to an empty string.  Downstream
+#   versions of QEMU should set this to a non-empty string.  The
+#   exact format depends on the downstream however it highly
+#   recommended that a unique name is used.
+#
+# Since: 0.14.0
+##
+{ 'type': 'VersionInfo',
+  'data': {'qemu': {'major': 'int', 'minor': 'int', 'micro': 'int'},
+   'package': 'str'} }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 14/72] qapi: Extract BlockDeviceIoStatus definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 15 ---
 qapi/block-core.json | 15 +++
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index cdfa222..408602b 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -664,21 +664,6 @@
 { 'command': 'query-iothreads', 'returns': ['IOThreadInfo'] }
 
 ##
-# @BlockDeviceIoStatus:
-#
-# An enumeration of block device I/O status.
-#
-# @ok: The last I/O operation has succeeded
-#
-# @failed: The last I/O operation has failed
-#
-# @nospace: The last I/O operation has failed due to a no-space condition
-#
-# Since: 1.0
-##
-{ 'enum': 'BlockDeviceIoStatus', 'data': [ 'ok', 'failed', 'nospace' ] }
-
-##
 # @BlockDeviceMapEntry:
 #
 # Entry in the metadata map of the device (returned by "qemu-img map")
diff --git a/qapi/block-core.json b/qapi/block-core.json
index e129db4..d355daa 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -250,3 +250,18 @@
 '*iops_rd_max': 'int', '*iops_wr_max': 'int',
 '*iops_size': 'int' } }
 
+##
+# @BlockDeviceIoStatus:
+#
+# An enumeration of block device I/O status.
+#
+# @ok: The last I/O operation has succeeded
+#
+# @failed: The last I/O operation has failed
+#
+# @nospace: The last I/O operation has failed due to a no-space condition
+#
+# Since: 1.0
+##
+{ 'enum': 'BlockDeviceIoStatus', 'data': [ 'ok', 'failed', 'nospace' ] }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 18/72] qapi: Extract query-block definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 11 ---
 qapi/block-core.json | 11 +++
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index ec1bb00..31102cf 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -664,17 +664,6 @@
 { 'command': 'query-iothreads', 'returns': ['IOThreadInfo'] }
 
 ##
-# @query-block:
-#
-# Get a list of BlockInfo for all virtual block devices.
-#
-# Returns: a list of @BlockInfo describing each virtual block device
-#
-# Since: 0.14.0
-##
-{ 'command': 'query-block', 'returns': ['BlockInfo'] }
-
-##
 # @BlockDeviceStats:
 #
 # Statistics of a virtual block device or a block backing device.
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 24d45f1..7be8ffe 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -344,3 +344,14 @@
'*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus',
'*dirty-bitmaps': ['BlockDirtyInfo'] } }
 
+##
+# @query-block:
+#
+# Get a list of BlockInfo for all virtual block devices.
+#
+# Returns: a list of @BlockInfo describing each virtual block device
+#
+# Since: 0.14.0
+##
+{ 'command': 'query-block', 'returns': ['BlockInfo'] }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 01/72] qapi: Extract ErrorClass definition in qapi/common.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 28 ++--
 qapi/common.json | 29 +
 2 files changed, 31 insertions(+), 26 deletions(-)
 create mode 100644 qapi/common.json

diff --git a/qapi-schema.json b/qapi-schema.json
index 0fd10b6..366a507 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -2,32 +2,8 @@
 #
 # QAPI Schema
 
-##
-# @ErrorClass
-#
-# QEMU error classes
-#
-# @GenericError: this is used for errors that don't require a specific error
-#class. This should be the default case for most errors
-#
-# @CommandNotFound: the requested command has not been found
-#
-# @DeviceEncrypted: the requested operation can't be fulfilled because the
-#   selected device is encrypted
-#
-# @DeviceNotActive: a device has failed to be become active
-#
-# @DeviceNotFound: the requested device has not been found
-#
-# @KVMMissingCap: the requested operation can't be fulfilled because a
-# required KVM capability is missing
-#
-# Since: 1.2
-##
-{ 'enum': 'ErrorClass',
-  'data': [ 'GenericError', 'CommandNotFound', 'DeviceEncrypted',
-'DeviceNotActive', 'DeviceNotFound', 'KVMMissingCap' ] }
-
+# QAPI common definitions
+{ 'include': 'qapi/common.json' }
 
 ##
 # LostTickPolicy:
diff --git a/qapi/common.json b/qapi/common.json
new file mode 100644
index 000..37f63a4
--- /dev/null
+++ b/qapi/common.json
@@ -0,0 +1,29 @@
+# -*- Mode: Python -*-
+#
+# QAPI common definitions
+
+##
+# @ErrorClass
+#
+# QEMU error classes
+#
+# @GenericError: this is used for errors that don't require a specific error
+#class. This should be the default case for most errors
+#
+# @CommandNotFound: the requested command has not been found
+#
+# @DeviceEncrypted: the requested operation can't be fulfilled because the
+#   selected device is encrypted
+#
+# @DeviceNotActive: a device has failed to be become active
+#
+# @DeviceNotFound: the requested device has not been found
+#
+# @KVMMissingCap: the requested operation can't be fulfilled because a
+# required KVM capability is missing
+#
+# Since: 1.2
+##
+{ 'enum': 'ErrorClass',
+  'data': [ 'GenericError', 'CommandNotFound', 'DeviceEncrypted',
+'DeviceNotActive', 'DeviceNotFound', 'KVMMissingCap' ] }
-- 
1.9.1




[Qemu-devel] [PATCH v1 08/72] qapi: Extract ImageInfoSpecificQCow2 definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 15 ---
 qapi/block-core.json | 15 +++
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 50cb25a..2507681 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -184,21 +184,6 @@
 'guest-panicked' ] }
 
 ##
-# @ImageInfoSpecificQCow2:
-#
-# @compat: compatibility level
-#
-# @lazy-refcounts: #optional on or off; only valid for compat >= 1.1
-#
-# Since: 1.7
-##
-{ 'type': 'ImageInfoSpecificQCow2',
-  'data': {
-  'compat': 'str',
-  '*lazy-refcounts': 'bool'
-  } }
-
-##
 # @ImageInfoSpecificVmdk:
 #
 # @create-type: The create type of VMDK image
diff --git a/qapi/block-core.json b/qapi/block-core.json
index f4948a4..3897c57 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -31,3 +31,18 @@
 'date-sec': 'int', 'date-nsec': 'int',
 'vm-clock-sec': 'int', 'vm-clock-nsec': 'int' } }
 
+##
+# @ImageInfoSpecificQCow2:
+#
+# @compat: compatibility level
+#
+# @lazy-refcounts: #optional on or off; only valid for compat >= 1.1
+#
+# Since: 1.7
+##
+{ 'type': 'ImageInfoSpecificQCow2',
+  'data': {
+  'compat': 'str',
+  '*lazy-refcounts': 'bool'
+  } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 06/72] qapi: create two block related json modules

2014-05-31 Thread Benoît Canet
qapi/block-core.json contains block definitions unrelated to emulation.

qapi/block.json is a superset of the previous and contains definitions related
to emulation.

The purpose of these extractions is to be able to hook qapi/block-core.json
generated code on qemu-nbd.

Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 3 +++
 qapi/block-core.json | 8 
 qapi/block.json  | 7 +++
 3 files changed, 18 insertions(+)
 create mode 100644 qapi/block-core.json
 create mode 100644 qapi/block.json

diff --git a/qapi-schema.json b/qapi-schema.json
index 1afe023..1ed5926 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -5,6 +5,9 @@
 # QAPI common definitions
 { 'include': 'qapi/common.json' }
 
+# QAPI block definitions
+{ 'include': 'qapi/block.json' }
+
 ##
 # LostTickPolicy:
 #
diff --git a/qapi/block-core.json b/qapi/block-core.json
new file mode 100644
index 000..fa48e63
--- /dev/null
+++ b/qapi/block-core.json
@@ -0,0 +1,8 @@
+# -*- Mode: Python -*-
+#
+# QAPI block core definitions (vm unrelated)
+
+# QAPI common definitions
+{ 'include': 'common.json' }
+
+
diff --git a/qapi/block.json b/qapi/block.json
new file mode 100644
index 000..e2b882f
--- /dev/null
+++ b/qapi/block.json
@@ -0,0 +1,7 @@
+# -*- Mode: Python -*-
+#
+# QAPI block definitions (vm related)
+
+# QAPI block core definitions
+{ 'include': 'block-core.json' }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 22/72] qapi: Extract BlockdevOnError definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 23 ---
 qapi/block-core.json | 23 +++
 2 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 25c594a..9fe1cbc 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1002,29 +1002,6 @@
 { 'command': 'query-pci', 'returns': ['PciInfo'] }
 
 ##
-# @BlockdevOnError:
-#
-# An enumeration of possible behaviors for errors on I/O operations.
-# The exact meaning depends on whether the I/O was initiated by a guest
-# or by a block job
-#
-# @report: for guest operations, report the error to the guest;
-#  for jobs, cancel the job
-#
-# @ignore: ignore the error, only report a QMP event (BLOCK_IO_ERROR
-#  or BLOCK_JOB_ERROR)
-#
-# @enospc: same as @stop on ENOSPC, same as @report otherwise.
-#
-# @stop: for guest operations, stop the virtual machine;
-#for jobs, pause the job
-#
-# Since: 1.3
-##
-{ 'enum': 'BlockdevOnError',
-  'data': ['report', 'ignore', 'enospc', 'stop'] }
-
-##
 # @MirrorSyncMode:
 #
 # An enumeration of possible behaviors for the initial synchronization
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 282154b..0f141d7 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -424,3 +424,26 @@
 ##
 { 'command': 'query-blockstats', 'returns': ['BlockStats'] }
 
+##
+# @BlockdevOnError:
+#
+# An enumeration of possible behaviors for errors on I/O operations.
+# The exact meaning depends on whether the I/O was initiated by a guest
+# or by a block job
+#
+# @report: for guest operations, report the error to the guest;
+#  for jobs, cancel the job
+#
+# @ignore: ignore the error, only report a QMP event (BLOCK_IO_ERROR
+#  or BLOCK_JOB_ERROR)
+#
+# @enospc: same as @stop on ENOSPC, same as @report otherwise.
+#
+# @stop: for guest operations, stop the virtual machine;
+#for jobs, pause the job
+#
+# Since: 1.3
+##
+{ 'enum': 'BlockdevOnError',
+  'data': ['report', 'ignore', 'enospc', 'stop'] }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 05/72] qapi: Extract query-commands definition into qapi/common.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 11 ---
 qapi/common.json | 11 +++
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 82d675e..1afe023 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -523,17 +523,6 @@
   'returns': 'str' }
 
 ##
-# @query-commands:
-#
-# Return a list of supported QMP commands by this server
-#
-# Returns: A list of @CommandInfo for all supported commands
-#
-# Since: 0.14.0
-##
-{ 'command': 'query-commands', 'returns': ['CommandInfo'] }
-
-##
 # @EventInfo:
 #
 # Information about a QMP event
diff --git a/qapi/common.json b/qapi/common.json
index 37caa5a..4e9a21f 100644
--- a/qapi/common.json
+++ b/qapi/common.json
@@ -76,3 +76,14 @@
 ##
 { 'type': 'CommandInfo', 'data': {'name': 'str'} }
 
+##
+# @query-commands:
+#
+# Return a list of supported QMP commands by this server
+#
+# Returns: A list of @CommandInfo for all supported commands
+#
+# Since: 0.14.0
+##
+{ 'command': 'query-commands', 'returns': ['CommandInfo'] }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 11/72] qapi: Extract ImageInfo definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 47 ---
 qapi/block-core.json | 47 +++
 2 files changed, 47 insertions(+), 47 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 26bf23f..fcccfe6 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -184,53 +184,6 @@
 'guest-panicked' ] }
 
 ##
-# @ImageInfo:
-#
-# Information about a QEMU image file
-#
-# @filename: name of the image file
-#
-# @format: format of the image file
-#
-# @virtual-size: maximum capacity in bytes of the image
-#
-# @actual-size: #optional actual size on disk in bytes of the image
-#
-# @dirty-flag: #optional true if image is not cleanly closed
-#
-# @cluster-size: #optional size of a cluster in bytes
-#
-# @encrypted: #optional true if the image is encrypted
-#
-# @compressed: #optional true if the image is compressed (Since 1.7)
-#
-# @backing-filename: #optional name of the backing file
-#
-# @full-backing-filename: #optional full path of the backing file
-#
-# @backing-filename-format: #optional the format of the backing file
-#
-# @snapshots: #optional list of VM snapshots
-#
-# @backing-image: #optional info of the backing image (since 1.6)
-#
-# @format-specific: #optional structure supplying additional format-specific
-# information (since 1.7)
-#
-# Since: 1.3
-#
-##
-
-{ 'type': 'ImageInfo',
-  'data': {'filename': 'str', 'format': 'str', '*dirty-flag': 'bool',
-   '*actual-size': 'int', 'virtual-size': 'int',
-   '*cluster-size': 'int', '*encrypted': 'bool', '*compressed': 'bool',
-   '*backing-filename': 'str', '*full-backing-filename': 'str',
-   '*backing-filename-format': 'str', '*snapshots': ['SnapshotInfo'],
-   '*backing-image': 'ImageInfo',
-   '*format-specific': 'ImageInfoSpecific' } }
-
-##
 # @ImageCheck:
 #
 # Information about a QEMU image file check
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 6aaddf7..bb0f0bf 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -81,3 +81,50 @@
   'vmdk': 'ImageInfoSpecificVmdk'
   } }
 
+##
+# @ImageInfo:
+#
+# Information about a QEMU image file
+#
+# @filename: name of the image file
+#
+# @format: format of the image file
+#
+# @virtual-size: maximum capacity in bytes of the image
+#
+# @actual-size: #optional actual size on disk in bytes of the image
+#
+# @dirty-flag: #optional true if image is not cleanly closed
+#
+# @cluster-size: #optional size of a cluster in bytes
+#
+# @encrypted: #optional true if the image is encrypted
+#
+# @compressed: #optional true if the image is compressed (Since 1.7)
+#
+# @backing-filename: #optional name of the backing file
+#
+# @full-backing-filename: #optional full path of the backing file
+#
+# @backing-filename-format: #optional the format of the backing file
+#
+# @snapshots: #optional list of VM snapshots
+#
+# @backing-image: #optional info of the backing image (since 1.6)
+#
+# @format-specific: #optional structure supplying additional format-specific
+# information (since 1.7)
+#
+# Since: 1.3
+#
+##
+
+{ 'type': 'ImageInfo',
+  'data': {'filename': 'str', 'format': 'str', '*dirty-flag': 'bool',
+   '*actual-size': 'int', 'virtual-size': 'int',
+   '*cluster-size': 'int', '*encrypted': 'bool', '*compressed': 'bool',
+   '*backing-filename': 'str', '*full-backing-filename': 'str',
+   '*backing-filename-format': 'str', '*snapshots': ['SnapshotInfo'],
+   '*backing-image': 'ImageInfo',
+   '*format-specific': 'ImageInfoSpecific' } }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 03/72] qapi: Extract query-version definition in qapi/common.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 11 ---
 qapi/common.json | 11 +++
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 915bd69..6d0aea2 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -110,17 +110,6 @@
 { 'command': 'query-name', 'returns': 'NameInfo' }
 
 ##
-# @query-version:
-#
-# Returns the current version of QEMU.
-#
-# Returns:  A @VersionInfo object describing the current version of QEMU.
-#
-# Since: 0.14.0
-##
-{ 'command': 'query-version', 'returns': 'VersionInfo' }
-
-##
 # @KvmInfo:
 #
 # Information about support for KVM acceleration
diff --git a/qapi/common.json b/qapi/common.json
index 36c625b..2f1093c 100644
--- a/qapi/common.json
+++ b/qapi/common.json
@@ -54,3 +54,14 @@
   'data': {'qemu': {'major': 'int', 'minor': 'int', 'micro': 'int'},
'package': 'str'} }
 
+##
+# @query-version:
+#
+# Returns the current version of QEMU.
+#
+# Returns:  A @VersionInfo object describing the current version of QEMU.
+#
+# Since: 0.14.0
+##
+{ 'command': 'query-version', 'returns': 'VersionInfo' }
+
-- 
1.9.1




[Qemu-devel] [PATCH v1 10/72] qapi: Extract ImageInfoSpecific definition into qapi/block-core.json

2014-05-31 Thread Benoît Canet
Signed-off-by: Benoit Canet 
---
 qapi-schema.json | 14 --
 qapi/block-core.json | 14 ++
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 0c517f4..26bf23f 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -184,20 +184,6 @@
 'guest-panicked' ] }
 
 ##
-# @ImageInfoSpecific:
-#
-# A discriminated record of image format specific information structures.
-#
-# Since: 1.7
-##
-
-{ 'union': 'ImageInfoSpecific',
-  'data': {
-  'qcow2': 'ImageInfoSpecificQCow2',
-  'vmdk': 'ImageInfoSpecificVmdk'
-  } }
-
-##
 # @ImageInfo:
 #
 # Information about a QEMU image file
diff --git a/qapi/block-core.json b/qapi/block-core.json
index ed853d9..6aaddf7 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -67,3 +67,17 @@
   'extents': ['ImageInfo']
   } }
 
+##
+# @ImageInfoSpecific:
+#
+# A discriminated record of image format specific information structures.
+#
+# Since: 1.7
+##
+
+{ 'union': 'ImageInfoSpecific',
+  'data': {
+  'qcow2': 'ImageInfoSpecificQCow2',
+  'vmdk': 'ImageInfoSpecificVmdk'
+  } }
+
-- 
1.9.1




[Qemu-devel] [RFC] image-fuzzer: Trivial test runner

2014-05-31 Thread Maria Kustova
This version of test runner executes only one test. In future it will be
extended to execute multiple tests in a run.

Signed-off-by: Maria Kustova 
---
 tests/image-fuzzer/runner.py | 225 +++
 1 file changed, 225 insertions(+)
 create mode 100644 tests/image-fuzzer/runner.py

diff --git a/tests/image-fuzzer/runner.py b/tests/image-fuzzer/runner.py
new file mode 100644
index 000..1dea8ef
--- /dev/null
+++ b/tests/image-fuzzer/runner.py
@@ -0,0 +1,225 @@
+# Tool for running fuzz tests
+#
+# Copyright (C) 2014 Maria Kustova 
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see .
+#
+
+import sys, os, signal
+import qcow2
+from time import gmtime, strftime
+import subprocess
+from shutil import rmtree
+import getopt
+# -For local test environment only
+import resource
+resource.setrlimit(resource.RLIMIT_CORE, (-1, -1))
+# -
+
+def multilog(msg, *output):
+""" Write an object to all of specified file descriptors
+"""
+
+for fd in output:
+fd.write(msg)
+fd.flush()
+
+
+def str_signal(sig):
+""" Convert a numeric value of a system signal to the string one
+defined by the current operational system
+"""
+
+for k, v in signal.__dict__.items():
+if v == sig:
+return k
+
+
+class TestEnv(object):
+""" Trivial test object
+
+The class sets up test environment, generates a test image and executes
+qemu_img with specified arguments and a test image provided. All logs
+are collected.
+Summary log will contain short descriptions and statuses of all tests in
+a run.
+Test log will include application ('qemu-img') logs besides info sent
+to the summary log.
+"""
+
+def __init__(self, work_dir, run_log, exec_bin=None, cleanup=True):
+"""Set test environment in a specified work directory.
+
+Path to qemu_img will be retrieved from 'QEMU_IMG' environment
+variable, if not specified.
+"""
+
+self.init_path = os.getcwd()
+self.work_dir = work_dir
+self.current_dir = os.path.join(work_dir, strftime("%Y_%m_%d_%H-%M-%S",
+   gmtime()))
+if exec_bin is not None:
+self.exec_bin = exec_bin.strip().split(' ')
+else:
+self.exec_bin = os.environ.get('QEMU_IMG', 'qemu-img').strip()\
+.split(' ')
+
+try:
+os.makedirs(self.current_dir)
+except OSError:
+e = sys.exc_info()[1]
+print >>sys.stderr, 'Error: The working directory cannot be used.'\
+' Reason: %s' %e[1]
+raise Exception('Internal error')
+
+self.log = open(os.path.join(self.current_dir, "test.log"), "w")
+self.parent_log = open(run_log, "a")
+self.result = False
+self.cleanup = cleanup
+
+def _qemu_img(self, q_args):
+""" Start qemu_img with specified arguments and return an exit code or
+a kill signal depending on result of an execution.
+"""
+devnull = open('/dev/null', 'r+')
+return subprocess.call(self.exec_bin \
+   + q_args +
+   ['test_image.qcow2'], stdin=devnull,
+   stdout=self.log, stderr=self.log)
+
+
+def execute(self, q_args, seed, size=8*512):
+""" Execute a test.
+
+The method creates a test image, runs 'qemu_img' and analyzes its exit
+status. If the application was killed by a signal, the test is marked
+as failed.
+"""
+os.chdir(self.current_dir)
+seed = qcow2.create_image('test_image.qcow2', seed, size)
+multilog("Seed: %s\nCommand: %s\nTest directory: %s\n"\
+ %(seed, " ".join(q_args), self.current_dir),\
+ sys.stdout, self.log, self.parent_log)
+try:
+retcode = self._qemu_img(q_args)
+except OSError:
+e = sys.exc_info()[1]
+multilog("Error: Start of 'qemu_img' failed. Reason: %s\n"\
+ %e[1], sys.stderr, self.log, self.parent_log)
+raise Exception('Internal error')
+
+if retcode < 0:
+multilog('FAIL: Test terminated by signal %s\n'
+ %str_signal(-retcode), sys.stderr, self.log, \
+ self.

  1   2   >