Merge remote-tracking branch 'qmp/queue/qmp' into staging

* qmp/queue/qmp:
  qapi: g_hash_table_find() instead of GHashTableIter.
  qmp: make block job command naming consistent
This commit is contained in:
Anthony Liguori 2012-04-23 14:29:11 -05:00
commit 6454678423
4 changed files with 34 additions and 24 deletions

View File

@ -1548,7 +1548,8 @@
'data': { 'device': 'str', 'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int', 'data': { 'device': 'str', 'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int',
'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int' } } 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int' } }
# @block_stream: ##
# @block-stream:
# #
# Copy data from a backing file into a block device. # Copy data from a backing file into a block device.
# #
@ -1556,7 +1557,7 @@
# backing file has been copied. This command returns immediately once streaming # backing file has been copied. This command returns immediately once streaming
# has started. The status of ongoing block streaming operations can be checked # 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 # with query-block-jobs. The operation can be stopped before it has completed
# using the block_job_cancel command. # using the block-job-cancel command.
# #
# If a base file is specified then sectors are not copied from that base file and # 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 # its backing chain. When streaming completes the image file will have the base
@ -1578,10 +1579,10 @@
# #
# Since: 1.1 # Since: 1.1
## ##
{ 'command': 'block_stream', 'data': { 'device': 'str', '*base': 'str' } } { 'command': 'block-stream', 'data': { 'device': 'str', '*base': 'str' } }
## ##
# @block_job_set_speed: # @block-job-set-speed:
# #
# Set maximum speed for a background block operation. # Set maximum speed for a background block operation.
# #
@ -1599,11 +1600,11 @@
# #
# Since: 1.1 # Since: 1.1
## ##
{ 'command': 'block_job_set_speed', { 'command': 'block-job-set-speed',
'data': { 'device': 'str', 'value': 'int' } } 'data': { 'device': 'str', 'value': 'int' } }
## ##
# @block_job_cancel: # @block-job-cancel:
# #
# Stop an active block streaming operation. # Stop an active block streaming operation.
# #
@ -1629,7 +1630,7 @@
# #
# Since: 1.1 # Since: 1.1
## ##
{ 'command': 'block_job_cancel', 'data': { 'device': 'str' } } { 'command': 'block-job-cancel', 'data': { 'device': 'str' } }
## ##
# @ObjectTypeInfo: # @ObjectTypeInfo:

View File

@ -87,20 +87,29 @@ static void qmp_input_push(QmpInputVisitor *qiv, QObject *obj, Error **errp)
qiv->nb_stack++; qiv->nb_stack++;
} }
/** Only for qmp_input_pop. */
static gboolean always_true(gpointer key, gpointer val, gpointer user_pkey)
{
*(const char **)user_pkey = (const char *)key;
return TRUE;
}
static void qmp_input_pop(QmpInputVisitor *qiv, Error **errp) static void qmp_input_pop(QmpInputVisitor *qiv, Error **errp)
{ {
GHashTableIter iter;
gpointer key;
if (qiv->strict && qiv->stack[qiv->nb_stack - 1].h) {
g_hash_table_iter_init(&iter, qiv->stack[qiv->nb_stack - 1].h);
if (g_hash_table_iter_next(&iter, &key, NULL)) {
error_set(errp, QERR_QMP_EXTRA_MEMBER, (char *) key);
}
g_hash_table_unref(qiv->stack[qiv->nb_stack - 1].h);
}
assert(qiv->nb_stack > 0); assert(qiv->nb_stack > 0);
if (qiv->strict) {
GHashTable * const top_ht = qiv->stack[qiv->nb_stack - 1].h;
if (top_ht) {
if (g_hash_table_size(top_ht)) {
const char *key;
g_hash_table_find(top_ht, always_true, &key);
error_set(errp, QERR_QMP_EXTRA_MEMBER, key);
}
g_hash_table_unref(top_ht);
}
}
qiv->nb_stack--; qiv->nb_stack--;
} }

View File

@ -687,19 +687,19 @@ Example:
EQMP EQMP
{ {
.name = "block_stream", .name = "block-stream",
.args_type = "device:B,base:s?", .args_type = "device:B,base:s?",
.mhandler.cmd_new = qmp_marshal_input_block_stream, .mhandler.cmd_new = qmp_marshal_input_block_stream,
}, },
{ {
.name = "block_job_set_speed", .name = "block-job-set-speed",
.args_type = "device:B,value:o", .args_type = "device:B,value:o",
.mhandler.cmd_new = qmp_marshal_input_block_job_set_speed, .mhandler.cmd_new = qmp_marshal_input_block_job_set_speed,
}, },
{ {
.name = "block_job_cancel", .name = "block-job-cancel",
.args_type = "device:B", .args_type = "device:B",
.mhandler.cmd_new = qmp_marshal_input_block_job_cancel, .mhandler.cmd_new = qmp_marshal_input_block_job_cancel,
}, },

View File

@ -49,7 +49,7 @@ class TestSingleDrive(ImageStreamingTestCase):
def test_stream(self): def test_stream(self):
self.assert_no_active_streams() self.assert_no_active_streams()
result = self.vm.qmp('block_stream', device='drive0') result = self.vm.qmp('block-stream', device='drive0')
self.assert_qmp(result, 'return', {}) self.assert_qmp(result, 'return', {})
completed = False completed = False
@ -68,7 +68,7 @@ class TestSingleDrive(ImageStreamingTestCase):
'image file not fully populated after streaming') 'image file not fully populated after streaming')
def test_device_not_found(self): def test_device_not_found(self):
result = self.vm.qmp('block_stream', device='nonexistent') result = self.vm.qmp('block-stream', device='nonexistent')
self.assert_qmp(result, 'error/class', 'DeviceNotFound') self.assert_qmp(result, 'error/class', 'DeviceNotFound')
class TestStreamStop(ImageStreamingTestCase): class TestStreamStop(ImageStreamingTestCase):
@ -90,14 +90,14 @@ class TestStreamStop(ImageStreamingTestCase):
self.assert_no_active_streams() self.assert_no_active_streams()
result = self.vm.qmp('block_stream', device='drive0') result = self.vm.qmp('block-stream', device='drive0')
self.assert_qmp(result, 'return', {}) self.assert_qmp(result, 'return', {})
time.sleep(1) time.sleep(1)
events = self.vm.get_qmp_events(wait=False) events = self.vm.get_qmp_events(wait=False)
self.assertEqual(events, [], 'unexpected QMP event: %s' % events) self.assertEqual(events, [], 'unexpected QMP event: %s' % events)
self.vm.qmp('block_job_cancel', device='drive0') self.vm.qmp('block-job-cancel', device='drive0')
self.assert_qmp(result, 'return', {}) self.assert_qmp(result, 'return', {})
cancelled = False cancelled = False
@ -129,10 +129,10 @@ class TestSetSpeed(ImageStreamingTestCase):
def perf_test_set_speed(self): def perf_test_set_speed(self):
self.assert_no_active_streams() self.assert_no_active_streams()
result = self.vm.qmp('block_stream', device='drive0') result = self.vm.qmp('block-stream', device='drive0')
self.assert_qmp(result, 'return', {}) self.assert_qmp(result, 'return', {})
result = self.vm.qmp('block_job_set_speed', device='drive0', value=8 * 1024 * 1024) result = self.vm.qmp('block-job-set-speed', device='drive0', value=8 * 1024 * 1024)
self.assert_qmp(result, 'return', {}) self.assert_qmp(result, 'return', {})
completed = False completed = False