[PATCH] net/vhost-user: Save ack_features to net_clients during vhost_user_start

2022-04-12 Thread Yi Wang
From: Liu Xiangyu 

During vhost_user_start, if openvswitch.service restart, cause the final 
features
not expected. Because qemu not save the ack_features promptly.

Signed-off-by: Liu Xiangyu 
Signed-off-by: Yi Wang 
---
 net/vhost-user.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/net/vhost-user.c b/net/vhost-user.c
index b1a0247..ce9dcb6 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -92,6 +92,10 @@ static int vhost_user_start(int queues, NetClientState 
*ncs[],
 goto err;
 }
 
+if (s->vhost_net) {
+s->acked_features = vhost_net_get_acked_features(net);
+}
+
 if (i == 0) {
 max_queues = vhost_net_get_max_queues(net);
 if (queues > max_queues) {
-- 
1.8.3.1



[PATCH] mirror: Avoid assertion failed in mirror_run

2021-12-07 Thread Yi Wang
From: Long YunJian 

when blockcommit from active leaf node, sometimes, we get assertion failed with
"mirror_run: Assertion `QLIST_EMPTY(>tracked_requests)' failed" messages.
According to the core file, we find bs->tracked_requests has IO request,
so assertion failed.
(gdb) bt
#0  0x7f410df707cf in raise () from /lib64/libc.so.6
#1  0x7f410df5ac05 in abort () from /lib64/libc.so.6
#2  0x7f410df5aad9 in __assert_fail_base.cold.0 () from /lib64/libc.so.6
#3  0x7f410df68db6 in __assert_fail () from /lib64/libc.so.6
#4  0x556915635371 in mirror_run (job=0x556916ff8600, errp=) 
at block/mirror.c:1092
#5  0x5569155e6c53 in job_co_entry (opaque=0x556916ff8600) at job.c:904
#6  0x5569156d9483 in coroutine_trampoline (i0=, 
i1=) at util/coroutine-ucontext.c:115
(gdb) p s->mirror_top_bs->backing->bs->tracked_requests
$12 = {lh_first = 0x7f3f07bfb8b0}
(gdb) p s->mirror_top_bs->backing->bs->tracked_requests->lh_first
$13 = (struct BdrvTrackedRequest *) 0x7f3f07bfb8b0

Actually, before excuting assert(QLIST_EMPTY(>tracked_requests)),
it will excute mirror_flush(s). It may handle new I/O request and maybe
pending I/O during this flush. Just likes in bdrv_close fuction,
bdrv_drain(bs) followed by bdrv_flush(bs), we should add bdrv_drain fuction
to handle pending I/O after mirror_flush.

Signed-off-by: Long YunJian 
Signed-off-by: Yi Wang 
---
 block/mirror.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/block/mirror.c b/block/mirror.c
index efec2c7674..1eec356310 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -1079,6 +1079,8 @@ static int coroutine_fn mirror_run(Job *job, Error **errp)
 s->in_drain = false;
 continue;
 }
+/* in case flush left pending I/O */
+bdrv_drain(bs);
 
 /* The two disks are in sync.  Exit and report successful
  * completion.
-- 
2.18.1



[PATCH v2] qga: fix a memory leak in qmp_guest_exec_status()

2021-06-30 Thread Yi Wang
From: Wang Yechao 

In some case, $GuestExecInfo.out.length maybe zero and the memory
is leaked in qmp_guest_exec_status(). Call g_free() on the fileds
directly to fix memory leak (NULL is ignored).

$GuestExecInfo.err.data has the same problem.

Signed-off-by: Yechao Wang 
Signed-off-by: Yi Wang 

---
Changes in v2:
 - do not check the size > 0 when call g_free. Thanks to Marc.
---
 qga/commands.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/qga/commands.c b/qga/commands.c
index d3fec80..26e9358 100644
--- a/qga/commands.c
+++ b/qga/commands.c
@@ -214,17 +214,18 @@ GuestExecStatus *qmp_guest_exec_status(int64_t pid, Error 
**errp)
 if (gei->out.length > 0) {
 ges->has_out_data = true;
 ges->out_data = g_base64_encode(gei->out.data, gei->out.length);
-g_free(gei->out.data);
 ges->has_out_truncated = gei->out.truncated;
 }
 
 if (gei->err.length > 0) {
 ges->has_err_data = true;
 ges->err_data = g_base64_encode(gei->err.data, gei->err.length);
-g_free(gei->err.data);
 ges->has_err_truncated = gei->err.truncated;
 }
 
+g_free(gei->out.data);
+g_free(gei->err.data);
+
 QTAILQ_REMOVE(_exec_state.processes, gei, next);
 g_free(gei);
 }
-- 
1.8.3.1

[PATCH] qga: fix a memory leak in qmp_guest_exec_status()

2021-06-30 Thread Yi Wang
From: Wang Yechao 

The $GuestExecInfo.out.data is alloced in guest_exec_output_watch(),
and the buffer size is $GuestExecInfo.out.size. We should free the
$GuestExecInfo.out.data judge by the size, not length. Because the
$GuestExecInfo.out.length maybe zero in some case.

$GuestExecInfo.err.data has the same problem.

Signed-off-by: Yechao Wang 
Signed-off-by: Yi Wang 
---
 qga/commands.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/qga/commands.c b/qga/commands.c
index d3fec80..58d4da9 100644
--- a/qga/commands.c
+++ b/qga/commands.c
@@ -214,17 +214,21 @@ GuestExecStatus *qmp_guest_exec_status(int64_t pid, Error 
**errp)
 if (gei->out.length > 0) {
 ges->has_out_data = true;
 ges->out_data = g_base64_encode(gei->out.data, gei->out.length);
-g_free(gei->out.data);
 ges->has_out_truncated = gei->out.truncated;
 }
 
 if (gei->err.length > 0) {
 ges->has_err_data = true;
 ges->err_data = g_base64_encode(gei->err.data, gei->err.length);
-g_free(gei->err.data);
 ges->has_err_truncated = gei->err.truncated;
 }
 
+if (gei->out.size > 0)
+g_free(gei->out.data);
+
+if (gei->err.size > 0)
+ g_free(gei->err.data);
+
 QTAILQ_REMOVE(_exec_state.processes, gei, next);
 g_free(gei);
 }
-- 
1.8.3.1

[PATCH] block: Change write_threshold to uint64 in BlockDeviceInfo

2021-03-01 Thread Yi Wang
From: renlei4 

write_threshold is saved as uint64, but BlockDeviceInfo use int to describe it.

normally it works well if threshold less than max int:
 # virsh domblkthreshold v6_163 sda 9223372036854775807
 # virsh qemu-monitor-command v6_163  '{ "execute": "query-named-block-nodes" 
}' |grep threshold
"write_threshold": 9223372036854775807,

overflow happened if threshold greater than max int:
 # virsh domblkthreshold v6_163 sda 9223372036854775811
 # virsh qemu-monitor-command v6_163   '{ "execute": "query-named-block-nodes" 
}' |grep threshold
"write_threshold": -9223372036854775805,

Fixes: e2462113b200 "block: add event when disk usage exceeds threshold"

Signed-off-by: Ren Lei 
Signed-off-by: Yi Wang 
---
 qapi/block-core.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qapi/block-core.json b/qapi/block-core.json
index 9f555d5..00b8729 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -409,7 +409,7 @@
 '*bps_wr_max_length': 'int', '*iops_max_length': 'int',
 '*iops_rd_max_length': 'int', '*iops_wr_max_length': 'int',
 '*iops_size': 'int', '*group': 'str', 'cache': 'BlockdevCacheInfo',
-'write_threshold': 'int', '*dirty-bitmaps': ['BlockDirtyInfo'] } }
+'write_threshold': 'uint64', '*dirty-bitmaps': ['BlockDirtyInfo'] 
} }
 
 ##
 # @BlockDeviceIoStatus:
-- 
1.8.3.1

[PATCH 10/12] target/openrisc: Remove superfluous breaks

2020-07-13 Thread Yi Wang
From: Liao Pingfang 

Remove superfluous breaks, as there is a "return" before them.

Signed-off-by: Liao Pingfang 
Signed-off-by: Yi Wang 
Reviewed-by: Philippe Mathieu-Daudé 
---
 target/openrisc/sys_helper.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c
index d9fe6c5..d9691d0 100644
--- a/target/openrisc/sys_helper.c
+++ b/target/openrisc/sys_helper.c
@@ -289,10 +289,8 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, 
target_ulong rd,
 
 case TO_SPR(5, 1):  /* MACLO */
 return (uint32_t)env->mac;
-break;
 case TO_SPR(5, 2):  /* MACHI */
 return env->mac >> 32;
-break;
 
 case TO_SPR(8, 0):  /* PMR */
 return env->pmr;
-- 
2.9.5




[PATCH 12/12] target/cris: Remove superfluous breaks

2020-07-13 Thread Yi Wang
From: Liao Pingfang 

Remove superfluous breaks, as there is a "return" before them.

Signed-off-by: Liao Pingfang 
Signed-off-by: Yi Wang 
Reviewed-by: Philippe Mathieu-Daudé 
---
 target/cris/translate.c | 7 +++
 target/cris/translate_v10.inc.c | 2 --
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/target/cris/translate.c b/target/cris/translate.c
index aaa46b5..64a478b 100644
--- a/target/cris/translate.c
+++ b/target/cris/translate.c
@@ -1178,12 +1178,11 @@ static inline void t_gen_zext(TCGv d, TCGv s, int size)
 static char memsize_char(int size)
 {
 switch (size) {
-case 1: return 'b';  break;
-case 2: return 'w';  break;
-case 4: return 'd';  break;
+case 1: return 'b';
+case 2: return 'w';
+case 4: return 'd';
 default:
 return 'x';
-break;
 }
 }
 #endif
diff --git a/target/cris/translate_v10.inc.c b/target/cris/translate_v10.inc.c
index ae34a0d..7f38fd2 100644
--- a/target/cris/translate_v10.inc.c
+++ b/target/cris/translate_v10.inc.c
@@ -1026,10 +1026,8 @@ static unsigned int dec10_ind(CPUCRISState *env, 
DisasContext *dc)
 switch (dc->opcode) {
 case CRISV10_IND_MOVE_M_R:
 return dec10_ind_move_m_r(env, dc, size);
-break;
 case CRISV10_IND_MOVE_R_M:
 return dec10_ind_move_r_m(dc, size);
-break;
 case CRISV10_IND_CMP:
 LOG_DIS("cmp size=%d op=%d %d\n",  size, dc->src, dc->dst);
 cris_cc_mask(dc, CC_MASK_NZVC);
-- 
2.9.5




[PATCH 07/12] vnc: Remove the superfluous break

2020-07-13 Thread Yi Wang
From: Liao Pingfang 

Remove the superfluous break, as there is a "return" before.

Signed-off-by: Liao Pingfang a
Signed-off-by: Yi Wang 
Reviewed-by: Philippe Mathieu-Daudé 
---
 ui/vnc-enc-tight.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c
index 1e08518..cebd358 100644
--- a/ui/vnc-enc-tight.c
+++ b/ui/vnc-enc-tight.c
@@ -1125,7 +1125,6 @@ static int send_palette_rect(VncState *vs, int x, int y,
 }
 default:
 return -1; /* No palette for 8bits colors */
-break;
 }
 bytes = w * h;
 vs->tight->tight.offset = bytes;
-- 
2.9.5




[PATCH 11/12] target/sh4: Remove superfluous breaks

2020-07-13 Thread Yi Wang
From: Liao Pingfang 

Remove superfluous breaks, as there is a "return" before them.

Signed-off-by: Liao Pingfang 
Signed-off-by: Yi Wang 
Reviewed-by: Philippe Mathieu-Daudé 
---
 target/sh4/translate.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/target/sh4/translate.c b/target/sh4/translate.c
index 6192d83..60c863d 100644
--- a/target/sh4/translate.c
+++ b/target/sh4/translate.c
@@ -1542,7 +1542,6 @@ static void _decode_opc(DisasContext * ctx)
 tcg_gen_qemu_ld_i32(REG(0), REG(B11_8), ctx->memidx,
 MO_TEUL | MO_UNALN);
 return;
-break;
 case 0x40e9:/* movua.l @Rm+,R0 */
 CHECK_SH4A
 /* Load non-boundary-aligned data */
@@ -1550,7 +1549,6 @@ static void _decode_opc(DisasContext * ctx)
 MO_TEUL | MO_UNALN);
 tcg_gen_addi_i32(REG(B11_8), REG(B11_8), 4);
 return;
-break;
 case 0x0029:   /* movt Rn */
 tcg_gen_mov_i32(REG(B11_8), cpu_sr_t);
return;
@@ -1638,7 +1636,6 @@ static void _decode_opc(DisasContext * ctx)
 CHECK_SH4A
 tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC);
 return;
-break;
 case 0x4024:   /* rotcl Rn */
{
TCGv tmp = tcg_temp_new();
-- 
2.9.5




[PATCH 09/12] hw: Remove superfluous breaks

2020-07-13 Thread Yi Wang
From: Liao Pingfang 

Remove superfluous breaks, as there is a "return" before them.

Signed-off-by: Liao Pingfang 
Signed-off-by: Yi Wang 
Reviewed-by: Philippe Mathieu-Daudé 
---
 hw/block/pflash_cfi01.c |  1 -
 hw/display/cirrus_vga.c |  1 -
 hw/display/qxl-logger.c |  2 --
 hw/gpio/max7310.c   |  3 ---
 hw/i386/intel_iommu.c   |  1 -
 hw/input/pxa2xx_keypad.c| 10 --
 hw/intc/armv7m_nvic.c   |  1 -
 hw/net/lan9118.c|  2 --
 hw/usb/ccid-card-emulated.c |  1 -
 9 files changed, 22 deletions(-)

diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
index 8ab1d66..f0fcd63 100644
--- a/hw/block/pflash_cfi01.c
+++ b/hw/block/pflash_cfi01.c
@@ -213,7 +213,6 @@ static uint32_t pflash_devid_query(PFlashCFI01 *pfl, hwaddr 
offset)
 default:
 trace_pflash_device_info(offset);
 return 0;
-break;
 }
 /* Replicate responses for each device in bank. */
 if (pfl->device_width < pfl->bank_width) {
diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
index 212d6f5..02d9ed0 100644
--- a/hw/display/cirrus_vga.c
+++ b/hw/display/cirrus_vga.c
@@ -1637,7 +1637,6 @@ static int cirrus_vga_read_cr(CirrusVGAState * s, 
unsigned reg_index)
return s->vga.cr[s->vga.cr_index];
 case 0x26: // Attribute Controller Index Readback (R)
return s->vga.ar_index & 0x3f;
-   break;
 default:
 qemu_log_mask(LOG_GUEST_ERROR,
   "cirrus: inport cr_index 0x%02x\n", reg_index);
diff --git a/hw/display/qxl-logger.c b/hw/display/qxl-logger.c
index 2ec6d8f..c15175b 100644
--- a/hw/display/qxl-logger.c
+++ b/hw/display/qxl-logger.c
@@ -161,7 +161,6 @@ static int qxl_log_cmd_draw(PCIQXLDevice *qxl, QXLDrawable 
*draw, int group_id)
 switch (draw->type) {
 case QXL_DRAW_COPY:
 return qxl_log_cmd_draw_copy(qxl, >u.copy, group_id);
-break;
 }
 return 0;
 }
@@ -180,7 +179,6 @@ static int qxl_log_cmd_draw_compat(PCIQXLDevice *qxl, 
QXLCompatDrawable *draw,
 switch (draw->type) {
 case QXL_DRAW_COPY:
 return qxl_log_cmd_draw_copy(qxl, >u.copy, group_id);
-break;
 }
 return 0;
 }
diff --git a/hw/gpio/max7310.c b/hw/gpio/max7310.c
index bebb403..4f78774 100644
--- a/hw/gpio/max7310.c
+++ b/hw/gpio/max7310.c
@@ -51,11 +51,9 @@ static uint8_t max7310_rx(I2CSlave *i2c)
 switch (s->command) {
 case 0x00: /* Input port */
 return s->level ^ s->polarity;
-break;
 
 case 0x01: /* Output port */
 return s->level & ~s->direction;
-break;
 
 case 0x02: /* Polarity inversion */
 return s->polarity;
@@ -65,7 +63,6 @@ static uint8_t max7310_rx(I2CSlave *i2c)
 
 case 0x04: /* Timeout */
 return s->status;
-break;
 
 case 0xff: /* Reserved */
 return 0xff;
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index c56398e..7b390ca 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -3163,7 +3163,6 @@ static int vtd_irte_get(IntelIOMMUState *iommu, uint16_t 
index,
   index, entry->irte.sid_vtype);
 /* Take this as verification failure. */
 return -VTD_FR_IR_SID_ERR;
-break;
 }
 }
 
diff --git a/hw/input/pxa2xx_keypad.c b/hw/input/pxa2xx_keypad.c
index 62aa6f6..7f2f739 100644
--- a/hw/input/pxa2xx_keypad.c
+++ b/hw/input/pxa2xx_keypad.c
@@ -192,10 +192,8 @@ static uint64_t pxa2xx_keypad_read(void *opaque, hwaddr 
offset,
 s->kpc &= ~(KPC_DI);
 qemu_irq_lower(s->irq);
 return tmp;
-break;
 case KPDK:
 return s->kpdk;
-break;
 case KPREC:
 tmp = s->kprec;
 if(tmp & KPREC_OF1)
@@ -207,31 +205,23 @@ static uint64_t pxa2xx_keypad_read(void *opaque, hwaddr 
offset,
 if(tmp & KPREC_UF0)
 s->kprec &= ~(KPREC_UF0);
 return tmp;
-break;
 case KPMK:
 tmp = s->kpmk;
 if(tmp & KPMK_MKP)
 s->kpmk &= ~(KPMK_MKP);
 return tmp;
-break;
 case KPAS:
 return s->kpas;
-break;
 case KPASMKP0:
 return s->kpasmkp[0];
-break;
 case KPASMKP1:
 return s->kpasmkp[1];
-break;
 case KPASMKP2:
 return s->kpasmkp[2];
-break;
 case KPASMKP3:
 return s->kpasmkp[3];
-break;
 case KPKDI:
 return s->kpkdi;
-break;
 default:
 qemu_log_mask(LOG_GUEST_ERROR,
   "%s: Bad read offset 0x%"HWADDR_PRIx"\n",
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
index 3c4b6e6..720ac97 100644
--- a/hw/intc/armv7m_nvic.c
+++ b/hw/intc/armv7m_nvic.c
@@ -1275,7 +1275,6 @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset,

[PATCH 08/12] block/vmdk: Remove superfluous breaks

2020-07-13 Thread Yi Wang
From: Liao Pingfang 

Remove superfluous breaks, as there is a "return" before them.

Signed-off-by: Liao Pingfang 
Signed-off-by: Yi Wang 
Reviewed-by: Philippe Mathieu-Daudé 
---
 block/vmdk.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/block/vmdk.c b/block/vmdk.c
index 28cec50..8f222e3 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -1053,14 +1053,11 @@ static int vmdk_open_sparse(BlockDriverState *bs, 
BdrvChild *file, int flags,
 switch (magic) {
 case VMDK3_MAGIC:
 return vmdk_open_vmfs_sparse(bs, file, flags, errp);
-break;
 case VMDK4_MAGIC:
 return vmdk_open_vmdk4(bs, file, flags, options, errp);
-break;
 default:
 error_setg(errp, "Image not in VMDK format");
 return -EINVAL;
-break;
 }
 }
 
-- 
2.9.5




[PATCH 06/12] migration/migration.c: Remove superfluous breaks

2020-07-13 Thread Yi Wang
From: Liao Pingfang 

Remove superfluous breaks, as there is a "return" before them.

Signed-off-by: Liao Pingfang 
Signed-off-by: Yi Wang 
Reviewed-by: Philippe Mathieu-Daudé 
---
 migration/migration.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/migration/migration.c b/migration/migration.c
index 92e44e0..2fd5fbb 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -985,7 +985,6 @@ static void fill_source_migration_info(MigrationInfo *info)
 /* no migration has happened ever */
 /* do not overwrite destination migration status */
 return;
-break;
 case MIGRATION_STATUS_SETUP:
 info->has_status = true;
 info->has_total_time = false;
@@ -1104,7 +1103,6 @@ static void fill_destination_migration_info(MigrationInfo 
*info)
 switch (mis->state) {
 case MIGRATION_STATUS_NONE:
 return;
-break;
 case MIGRATION_STATUS_SETUP:
 case MIGRATION_STATUS_CANCELLING:
 case MIGRATION_STATUS_CANCELLED:
-- 
2.9.5




[PATCH 02/12] target/ppc: Remove superfluous breaks

2020-07-13 Thread Yi Wang
From: Liao Pingfang 

Remove superfluous breaks, as there is a "return" before them.

Signed-off-by: Liao Pingfang 
Signed-off-by: Yi Wang 
Reviewed-by: Philippe Mathieu-Daudé  
---
 target/ppc/misc_helper.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/target/ppc/misc_helper.c b/target/ppc/misc_helper.c
index 55b68d1..e43a3b4 100644
--- a/target/ppc/misc_helper.c
+++ b/target/ppc/misc_helper.c
@@ -234,25 +234,20 @@ target_ulong helper_clcs(CPUPPCState *env, uint32_t arg)
 case 0x0CUL:
 /* Instruction cache line size */
 return env->icache_line_size;
-break;
 case 0x0DUL:
 /* Data cache line size */
 return env->dcache_line_size;
-break;
 case 0x0EUL:
 /* Minimum cache line size */
 return (env->icache_line_size < env->dcache_line_size) ?
 env->icache_line_size : env->dcache_line_size;
-break;
 case 0x0FUL:
 /* Maximum cache line size */
 return (env->icache_line_size > env->dcache_line_size) ?
 env->icache_line_size : env->dcache_line_size;
-break;
 default:
 /* Undefined */
 return 0;
-break;
 }
 }
 
-- 
2.9.5




[PATCH 05/12] virtfs-proxy-helper: Remove the superfluous break

2020-07-13 Thread Yi Wang
From: Liao Pingfang 

Remove the superfluous break, as there is a "return" before it.

Signed-off-by: Liao Pingfang 
Signed-off-by: Yi Wang 
Reviewed-by: Philippe Mathieu-Daudé  
---
 fsdev/virtfs-proxy-helper.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c
index de061a8..e68acc1 100644
--- a/fsdev/virtfs-proxy-helper.c
+++ b/fsdev/virtfs-proxy-helper.c
@@ -825,7 +825,6 @@ static int process_reply(int sock, int type,
 break;
 default:
 return -1;
-break;
 }
 return 0;
 }
-- 
2.9.5




[PATCH 04/12] scsi: Remove superfluous breaks

2020-07-13 Thread Yi Wang
From: Liao Pingfang 

Remove superfluous breaks, as there is a "return" before them.

Signed-off-by: Liao Pingfang 
Signed-off-by: Yi Wang 
Reviewed-by: Philippe Mathieu-Daudé  
---
 scsi/utils.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/scsi/utils.c b/scsi/utils.c
index c50e81f..b37c283 100644
--- a/scsi/utils.c
+++ b/scsi/utils.c
@@ -32,17 +32,13 @@ uint32_t scsi_cdb_xfer(uint8_t *buf)
 switch (buf[0] >> 5) {
 case 0:
 return buf[4];
-break;
 case 1:
 case 2:
 return lduw_be_p([7]);
-break;
 case 4:
 return ldl_be_p([10]) & 0xULL;
-break;
 case 5:
 return ldl_be_p([6]) & 0xULL;
-break;
 default:
 return -1;
 }
-- 
2.9.5




[PATCH 03/12] tcg/riscv: Remove superfluous breaks

2020-07-13 Thread Yi Wang
From: Liao Pingfang 

Remove superfluous breaks, as there is a "return" before them.

Signed-off-by: Liao Pingfang 
Signed-off-by: Yi Wang 
Reviewed-by: Philippe Mathieu-Daudé  
---
 tcg/riscv/tcg-target.inc.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c
index 2bc0ba7..3c11ab8 100644
--- a/tcg/riscv/tcg-target.inc.c
+++ b/tcg/riscv/tcg-target.inc.c
@@ -502,10 +502,8 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type,
 break;
 case R_RISCV_JAL:
 return reloc_jimm20(code_ptr, (tcg_insn_unit *)value);
-break;
 case R_RISCV_CALL:
 return reloc_call(code_ptr, (tcg_insn_unit *)value);
-break;
 default:
 tcg_abort();
 }
-- 
2.9.5




[PATCH 01/12] target/arm/kvm: Remove superfluous break

2020-07-13 Thread Yi Wang
From: Liao Pingfang 

Remove superfluous break.

Signed-off-by: Liao Pingfang 
Signed-off-by: Yi Wang 
Reviewed-by: Philippe Mathieu-Daudé  
---
 target/arm/kvm64.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
index 1169237..ef1e960 100644
--- a/target/arm/kvm64.c
+++ b/target/arm/kvm64.c
@@ -330,7 +330,6 @@ int kvm_arch_remove_hw_breakpoint(target_ulong addr,
 switch (type) {
 case GDB_BREAKPOINT_HW:
 return delete_hw_breakpoint(addr);
-break;
 case GDB_WATCHPOINT_READ:
 case GDB_WATCHPOINT_WRITE:
 case GDB_WATCHPOINT_ACCESS:
-- 
2.9.5




[PATCH] target/openrisc: Remove superfluous breaks

2020-07-12 Thread Yi Wang
From: Liao Pingfang 

Remove superfluous breaks, as there is a "return" before them.

Signed-off-by: Liao Pingfang 
---
 target/openrisc/sys_helper.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c
index d9fe6c5..d9691d0 100644
--- a/target/openrisc/sys_helper.c
+++ b/target/openrisc/sys_helper.c
@@ -289,10 +289,8 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, 
target_ulong rd,
 
 case TO_SPR(5, 1):  /* MACLO */
 return (uint32_t)env->mac;
-break;
 case TO_SPR(5, 2):  /* MACHI */
 return env->mac >> 32;
-break;
 
 case TO_SPR(8, 0):  /* PMR */
 return env->pmr;
-- 
2.9.5




[PATCH] hw: Remove superfluous breaks

2020-07-12 Thread Yi Wang
From: Liao Pingfang 

Remove superfluous breaks, as there is a "return" before them.

Signed-off-by: Liao Pingfang 
---
 hw/block/pflash_cfi01.c |  1 -
 hw/display/cirrus_vga.c |  1 -
 hw/display/qxl-logger.c |  2 --
 hw/gpio/max7310.c   |  3 ---
 hw/i386/intel_iommu.c   |  1 -
 hw/input/pxa2xx_keypad.c| 10 --
 hw/intc/armv7m_nvic.c   |  1 -
 hw/net/lan9118.c|  2 --
 hw/usb/ccid-card-emulated.c |  1 -
 9 files changed, 22 deletions(-)

diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
index 8ab1d66..f0fcd63 100644
--- a/hw/block/pflash_cfi01.c
+++ b/hw/block/pflash_cfi01.c
@@ -213,7 +213,6 @@ static uint32_t pflash_devid_query(PFlashCFI01 *pfl, hwaddr 
offset)
 default:
 trace_pflash_device_info(offset);
 return 0;
-break;
 }
 /* Replicate responses for each device in bank. */
 if (pfl->device_width < pfl->bank_width) {
diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
index 212d6f5..02d9ed0 100644
--- a/hw/display/cirrus_vga.c
+++ b/hw/display/cirrus_vga.c
@@ -1637,7 +1637,6 @@ static int cirrus_vga_read_cr(CirrusVGAState * s, 
unsigned reg_index)
return s->vga.cr[s->vga.cr_index];
 case 0x26: // Attribute Controller Index Readback (R)
return s->vga.ar_index & 0x3f;
-   break;
 default:
 qemu_log_mask(LOG_GUEST_ERROR,
   "cirrus: inport cr_index 0x%02x\n", reg_index);
diff --git a/hw/display/qxl-logger.c b/hw/display/qxl-logger.c
index 2ec6d8f..c15175b 100644
--- a/hw/display/qxl-logger.c
+++ b/hw/display/qxl-logger.c
@@ -161,7 +161,6 @@ static int qxl_log_cmd_draw(PCIQXLDevice *qxl, QXLDrawable 
*draw, int group_id)
 switch (draw->type) {
 case QXL_DRAW_COPY:
 return qxl_log_cmd_draw_copy(qxl, >u.copy, group_id);
-break;
 }
 return 0;
 }
@@ -180,7 +179,6 @@ static int qxl_log_cmd_draw_compat(PCIQXLDevice *qxl, 
QXLCompatDrawable *draw,
 switch (draw->type) {
 case QXL_DRAW_COPY:
 return qxl_log_cmd_draw_copy(qxl, >u.copy, group_id);
-break;
 }
 return 0;
 }
diff --git a/hw/gpio/max7310.c b/hw/gpio/max7310.c
index bebb403..4f78774 100644
--- a/hw/gpio/max7310.c
+++ b/hw/gpio/max7310.c
@@ -51,11 +51,9 @@ static uint8_t max7310_rx(I2CSlave *i2c)
 switch (s->command) {
 case 0x00: /* Input port */
 return s->level ^ s->polarity;
-break;
 
 case 0x01: /* Output port */
 return s->level & ~s->direction;
-break;
 
 case 0x02: /* Polarity inversion */
 return s->polarity;
@@ -65,7 +63,6 @@ static uint8_t max7310_rx(I2CSlave *i2c)
 
 case 0x04: /* Timeout */
 return s->status;
-break;
 
 case 0xff: /* Reserved */
 return 0xff;
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index c56398e..7b390ca 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -3163,7 +3163,6 @@ static int vtd_irte_get(IntelIOMMUState *iommu, uint16_t 
index,
   index, entry->irte.sid_vtype);
 /* Take this as verification failure. */
 return -VTD_FR_IR_SID_ERR;
-break;
 }
 }
 
diff --git a/hw/input/pxa2xx_keypad.c b/hw/input/pxa2xx_keypad.c
index 62aa6f6..7f2f739 100644
--- a/hw/input/pxa2xx_keypad.c
+++ b/hw/input/pxa2xx_keypad.c
@@ -192,10 +192,8 @@ static uint64_t pxa2xx_keypad_read(void *opaque, hwaddr 
offset,
 s->kpc &= ~(KPC_DI);
 qemu_irq_lower(s->irq);
 return tmp;
-break;
 case KPDK:
 return s->kpdk;
-break;
 case KPREC:
 tmp = s->kprec;
 if(tmp & KPREC_OF1)
@@ -207,31 +205,23 @@ static uint64_t pxa2xx_keypad_read(void *opaque, hwaddr 
offset,
 if(tmp & KPREC_UF0)
 s->kprec &= ~(KPREC_UF0);
 return tmp;
-break;
 case KPMK:
 tmp = s->kpmk;
 if(tmp & KPMK_MKP)
 s->kpmk &= ~(KPMK_MKP);
 return tmp;
-break;
 case KPAS:
 return s->kpas;
-break;
 case KPASMKP0:
 return s->kpasmkp[0];
-break;
 case KPASMKP1:
 return s->kpasmkp[1];
-break;
 case KPASMKP2:
 return s->kpasmkp[2];
-break;
 case KPASMKP3:
 return s->kpasmkp[3];
-break;
 case KPKDI:
 return s->kpkdi;
-break;
 default:
 qemu_log_mask(LOG_GUEST_ERROR,
   "%s: Bad read offset 0x%"HWADDR_PRIx"\n",
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
index 3c4b6e6..720ac97 100644
--- a/hw/intc/armv7m_nvic.c
+++ b/hw/intc/armv7m_nvic.c
@@ -1275,7 +1275,6 @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, 
MemTxAttrs attrs)
 case 0xd90: /* MPU_TYPE */
 /* Unified MPU; if the MPU is not present this value is zero */
 return cpu->pmsav7_dregion << 8;
-break;
 case 0xd94: /* MPU_CTRL */
 

[PATCH] target/ppc: Remove superfluous breaks

2020-07-12 Thread Yi Wang
From: Liao Pingfang 

Remove superfluous breaks, as there is a "return" before them.

Signed-off-by: Liao Pingfang 
---
 target/ppc/misc_helper.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/target/ppc/misc_helper.c b/target/ppc/misc_helper.c
index 55b68d1..e43a3b4 100644
--- a/target/ppc/misc_helper.c
+++ b/target/ppc/misc_helper.c
@@ -234,25 +234,20 @@ target_ulong helper_clcs(CPUPPCState *env, uint32_t arg)
 case 0x0CUL:
 /* Instruction cache line size */
 return env->icache_line_size;
-break;
 case 0x0DUL:
 /* Data cache line size */
 return env->dcache_line_size;
-break;
 case 0x0EUL:
 /* Minimum cache line size */
 return (env->icache_line_size < env->dcache_line_size) ?
 env->icache_line_size : env->dcache_line_size;
-break;
 case 0x0FUL:
 /* Maximum cache line size */
 return (env->icache_line_size > env->dcache_line_size) ?
 env->icache_line_size : env->dcache_line_size;
-break;
 default:
 /* Undefined */
 return 0;
-break;
 }
 }
 
-- 
2.9.5




[PATCH] target/sh4: Remove superfluous breaks

2020-07-12 Thread Yi Wang
From: Liao Pingfang 

Remove superfluous breaks, as there is a "return" before them.

Signed-off-by: Liao Pingfang 
---
 target/sh4/translate.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/target/sh4/translate.c b/target/sh4/translate.c
index 6192d83..60c863d 100644
--- a/target/sh4/translate.c
+++ b/target/sh4/translate.c
@@ -1542,7 +1542,6 @@ static void _decode_opc(DisasContext * ctx)
 tcg_gen_qemu_ld_i32(REG(0), REG(B11_8), ctx->memidx,
 MO_TEUL | MO_UNALN);
 return;
-break;
 case 0x40e9:/* movua.l @Rm+,R0 */
 CHECK_SH4A
 /* Load non-boundary-aligned data */
@@ -1550,7 +1549,6 @@ static void _decode_opc(DisasContext * ctx)
 MO_TEUL | MO_UNALN);
 tcg_gen_addi_i32(REG(B11_8), REG(B11_8), 4);
 return;
-break;
 case 0x0029:   /* movt Rn */
 tcg_gen_mov_i32(REG(B11_8), cpu_sr_t);
return;
@@ -1638,7 +1636,6 @@ static void _decode_opc(DisasContext * ctx)
 CHECK_SH4A
 tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC);
 return;
-break;
 case 0x4024:   /* rotcl Rn */
{
TCGv tmp = tcg_temp_new();
-- 
2.9.5




[PATCH] scsi: Remove superfluous breaks

2020-07-12 Thread Yi Wang
From: Liao Pingfang 

Remove superfluous breaks, as there is a "return" before them.

Signed-off-by: Liao Pingfang 
---
 scsi/utils.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/scsi/utils.c b/scsi/utils.c
index c50e81f..b37c283 100644
--- a/scsi/utils.c
+++ b/scsi/utils.c
@@ -32,17 +32,13 @@ uint32_t scsi_cdb_xfer(uint8_t *buf)
 switch (buf[0] >> 5) {
 case 0:
 return buf[4];
-break;
 case 1:
 case 2:
 return lduw_be_p([7]);
-break;
 case 4:
 return ldl_be_p([10]) & 0xULL;
-break;
 case 5:
 return ldl_be_p([6]) & 0xULL;
-break;
 default:
 return -1;
 }
-- 
2.9.5




[PATCH] block/vmdk: Remove superfluous breaks

2020-07-12 Thread Yi Wang
From: Liao Pingfang 

Remove superfluous breaks, as there is a "return" before them.

Signed-off-by: Liao Pingfang 
---
 block/vmdk.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/block/vmdk.c b/block/vmdk.c
index 28cec50..8f222e3 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -1053,14 +1053,11 @@ static int vmdk_open_sparse(BlockDriverState *bs, 
BdrvChild *file, int flags,
 switch (magic) {
 case VMDK3_MAGIC:
 return vmdk_open_vmfs_sparse(bs, file, flags, errp);
-break;
 case VMDK4_MAGIC:
 return vmdk_open_vmdk4(bs, file, flags, options, errp);
-break;
 default:
 error_setg(errp, "Image not in VMDK format");
 return -EINVAL;
-break;
 }
 }
 
-- 
2.9.5




[PATCH] target/arm/kvm: Remove superfluous break

2020-07-12 Thread Yi Wang
From: Liao Pingfang 

Remove superfluous break.

Signed-off-by: Liao Pingfang 
---
 target/arm/kvm64.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
index 1169237..ef1e960 100644
--- a/target/arm/kvm64.c
+++ b/target/arm/kvm64.c
@@ -330,7 +330,6 @@ int kvm_arch_remove_hw_breakpoint(target_ulong addr,
 switch (type) {
 case GDB_BREAKPOINT_HW:
 return delete_hw_breakpoint(addr);
-break;
 case GDB_WATCHPOINT_READ:
 case GDB_WATCHPOINT_WRITE:
 case GDB_WATCHPOINT_ACCESS:
-- 
2.9.5




[PATCH] migration/migration.c: Remove superfluous breaks

2020-07-12 Thread Yi Wang
From: Liao Pingfang 

Remove superfluous breaks, as there is a "return" before them.

Signed-off-by: Liao Pingfang 
---
 migration/migration.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/migration/migration.c b/migration/migration.c
index 92e44e0..2fd5fbb 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -985,7 +985,6 @@ static void fill_source_migration_info(MigrationInfo *info)
 /* no migration has happened ever */
 /* do not overwrite destination migration status */
 return;
-break;
 case MIGRATION_STATUS_SETUP:
 info->has_status = true;
 info->has_total_time = false;
@@ -1104,7 +1103,6 @@ static void fill_destination_migration_info(MigrationInfo 
*info)
 switch (mis->state) {
 case MIGRATION_STATUS_NONE:
 return;
-break;
 case MIGRATION_STATUS_SETUP:
 case MIGRATION_STATUS_CANCELLING:
 case MIGRATION_STATUS_CANCELLED:
-- 
2.9.5




[PATCH] target/cris: Remove superfluous breaks

2020-07-12 Thread Yi Wang
From: Liao Pingfang 

Remove superfluous breaks, as there is a "return" before them.

Signed-off-by: Liao Pingfang 
---
 target/cris/translate.c | 7 +++
 target/cris/translate_v10.inc.c | 2 --
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/target/cris/translate.c b/target/cris/translate.c
index aaa46b5..64a478b 100644
--- a/target/cris/translate.c
+++ b/target/cris/translate.c
@@ -1178,12 +1178,11 @@ static inline void t_gen_zext(TCGv d, TCGv s, int size)
 static char memsize_char(int size)
 {
 switch (size) {
-case 1: return 'b';  break;
-case 2: return 'w';  break;
-case 4: return 'd';  break;
+case 1: return 'b';
+case 2: return 'w';
+case 4: return 'd';
 default:
 return 'x';
-break;
 }
 }
 #endif
diff --git a/target/cris/translate_v10.inc.c b/target/cris/translate_v10.inc.c
index ae34a0d..7f38fd2 100644
--- a/target/cris/translate_v10.inc.c
+++ b/target/cris/translate_v10.inc.c
@@ -1026,10 +1026,8 @@ static unsigned int dec10_ind(CPUCRISState *env, 
DisasContext *dc)
 switch (dc->opcode) {
 case CRISV10_IND_MOVE_M_R:
 return dec10_ind_move_m_r(env, dc, size);
-break;
 case CRISV10_IND_MOVE_R_M:
 return dec10_ind_move_r_m(dc, size);
-break;
 case CRISV10_IND_CMP:
 LOG_DIS("cmp size=%d op=%d %d\n",  size, dc->src, dc->dst);
 cris_cc_mask(dc, CC_MASK_NZVC);
-- 
2.9.5




[PATCH] vnc: Remove the superfluous break

2020-07-12 Thread Yi Wang
From: Liao Pingfang 

Remove the superfluous break, as there is a "return" before.

Signed-off-by: Liao Pingfang 
---
 ui/vnc-enc-tight.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c
index 1e08518..cebd358 100644
--- a/ui/vnc-enc-tight.c
+++ b/ui/vnc-enc-tight.c
@@ -1125,7 +1125,6 @@ static int send_palette_rect(VncState *vs, int x, int y,
 }
 default:
 return -1; /* No palette for 8bits colors */
-break;
 }
 bytes = w * h;
 vs->tight->tight.offset = bytes;
-- 
2.9.5




[PATCH] virtfs-proxy-helper: Remove the superfluous break

2020-07-12 Thread Yi Wang
From: Liao Pingfang 

Remove the superfluous break, as there is a "return" before it.

Signed-off-by: Liao Pingfang 
---
 fsdev/virtfs-proxy-helper.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c
index de061a8..e68acc1 100644
--- a/fsdev/virtfs-proxy-helper.c
+++ b/fsdev/virtfs-proxy-helper.c
@@ -825,7 +825,6 @@ static int process_reply(int sock, int type,
 break;
 default:
 return -1;
-break;
 }
 return 0;
 }
-- 
2.9.5




[PATCH] tcg/riscv: Remove superfluous breaks

2020-07-12 Thread Yi Wang
From: Liao Pingfang 

Remove superfluous breaks, as there is a "return" before them.

Signed-off-by: Liao Pingfang 
---
 tcg/riscv/tcg-target.inc.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c
index 2bc0ba7..3c11ab8 100644
--- a/tcg/riscv/tcg-target.inc.c
+++ b/tcg/riscv/tcg-target.inc.c
@@ -502,10 +502,8 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type,
 break;
 case R_RISCV_JAL:
 return reloc_jimm20(code_ptr, (tcg_insn_unit *)value);
-break;
 case R_RISCV_CALL:
 return reloc_call(code_ptr, (tcg_insn_unit *)value);
-break;
 default:
 tcg_abort();
 }
-- 
2.9.5




[PATCH] Makefile: Install qemu-[qmp/ga]-ref.* into the directory "interop"

2020-06-08 Thread Yi Wang
From: Liao Pingfang 

We need install qemu-[qmp/ga]-ref.* files into the subdirectory of qemu docs: 
interop.

If we visit the following address and click the link to qemu-qmp-ref.html:
https://www.qemu.org/docs/master/interop/bitmaps.html#basic-qmp-usage

It will report following error:
"
Not Found
The requested URL /docs/master/interop/qemu-qmp-ref.html was not found on this 
server.
"

Signed-off-by: Liao Pingfang 
---
 Makefile   | 10 ++
 docs/index.html.in |  4 ++--
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 40e4f76..49dbe7a 100644
--- a/Makefile
+++ b/Makefile
@@ -879,8 +879,9 @@ install-sphinxdocs: sphinxdocs
 install-doc: $(DOCS) install-sphinxdocs
$(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)"
$(INSTALL_DATA) $(MANUAL_BUILDDIR)/index.html "$(DESTDIR)$(qemu_docdir)"
-   $(INSTALL_DATA) docs/interop/qemu-qmp-ref.html 
"$(DESTDIR)$(qemu_docdir)"
-   $(INSTALL_DATA) docs/interop/qemu-qmp-ref.txt "$(DESTDIR)$(qemu_docdir)"
+   $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/interop"
+   $(INSTALL_DATA) docs/interop/qemu-qmp-ref.html 
"$(DESTDIR)$(qemu_docdir)/interop"
+   $(INSTALL_DATA) docs/interop/qemu-qmp-ref.txt 
"$(DESTDIR)$(qemu_docdir)/interop"
 ifdef CONFIG_POSIX
$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
$(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu.1 
"$(DESTDIR)$(mandir)/man1"
@@ -898,8 +899,9 @@ ifdef CONFIG_TRACE_SYSTEMTAP
 endif
 ifneq (,$(findstring qemu-ga,$(TOOLS)))
$(INSTALL_DATA) $(MANUAL_BUILDDIR)/interop/qemu-ga.8 
"$(DESTDIR)$(mandir)/man8"
-   $(INSTALL_DATA) docs/interop/qemu-ga-ref.html "$(DESTDIR)$(qemu_docdir)"
-   $(INSTALL_DATA) docs/interop/qemu-ga-ref.txt "$(DESTDIR)$(qemu_docdir)"
+   $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/interop"
+   $(INSTALL_DATA) docs/interop/qemu-ga-ref.html 
"$(DESTDIR)$(qemu_docdir)/interop"
+   $(INSTALL_DATA) docs/interop/qemu-ga-ref.txt 
"$(DESTDIR)$(qemu_docdir)/interop"
$(INSTALL_DATA) docs/interop/qemu-ga-ref.7 "$(DESTDIR)$(mandir)/man7"
 endif
 endif
diff --git a/docs/index.html.in b/docs/index.html.in
index e9a1603..6736fa4 100644
--- a/docs/index.html.in
+++ b/docs/index.html.in
@@ -12,8 +12,8 @@
 Tools Guide
 System Emulation Management and 
Interoperability Guide
 System Emulation Guest Hardware 
Specifications
-QMP Reference Manual
-Guest Agent Protocol 
Reference
+QMP Reference 
Manual
+Guest Agent Protocol 
Reference
 
 
 
-- 
2.9.5




[PATCH] virtio: add check for inconsistent VQ in virtio_save()

2019-10-30 Thread Yi Wang
From: Cheng Lin 

In a case, we have an not enabled VQ (virtio-net) which desc is NULL
and get a last_avail_idx is not 0 from dpdk.

As a result, it is successed to create a snapshot, but failed to revert it.
Because in virtio_load(), there is an inconsistent check for VQ.
(call virtio_load() in revert, and virtio_save() in create.)

Correspondly, in virtio_save() should also do this check to find the error
as early as possible.

Signed-off-by: Cheng Lin 
---
 hw/virtio/virtio.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 2e91dec..eadbf64 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -2792,6 +2792,12 @@ int virtio_save(VirtIODevice *vdev, QEMUFile *f)
  * Save desc now, the rest of the ring addresses are saved in
  * subsections for VIRTIO-1 devices.
  */
+if (!vdev->vq[i].vring.desc && vdev->vq[i].last_avail_idx) {
+error_report("VQ %d address 0x0 "
+ "inconsistent with Host index 0x%x",
+ i, vdev->vq[i].last_avail_idx);
+return -1;
+}
 qemu_put_be64(f, vdev->vq[i].vring.desc);
 qemu_put_be16s(f, >vq[i].last_avail_idx);
 if (k->save_queue) {
-- 
2.7.2.windows.1




[Qemu-devel] [PATCH] migration: update comments of migration bitmap

2019-04-15 Thread Yi Wang
Since the ram bitmap and the unsent bitmap are split by RAMBlock
in commit 6b6712e, it's better to update the comments about them.

Signed-off-by: Yi Wang 
---
 migration/ram.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/migration/ram.c b/migration/ram.c
index 1ca9ba7..24ab23d 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1630,8 +1630,6 @@ static int save_xbzrle_page(RAMState *rs, uint8_t 
**current_data,
 /**
  * migration_bitmap_find_dirty: find the next dirty page from start
  *
- * Called with rcu_read_lock() to protect migration_bitmap
- *
  * Returns the byte offset within memory region of the start of a dirty page
  *
  * @rs: current RAM state
@@ -2681,7 +2679,7 @@ static void ram_save_cleanup(void *opaque)
 RAMBlock *block;
 
 /* caller have hold iothread lock or is in a bh, so there is
- * no writing race against this migration_bitmap
+ * no writing race against the migration bitmap
  */
 memory_global_dirty_log_stop();
 
-- 
1.8.3.1




[Qemu-devel] [PATCH v2 1/2] hmp: dump ids including socket-id, core-id and so on for 'info registers'

2017-07-26 Thread Yi Wang
This patch add output of CPUs' socket-id, core-id, thread-id and
apic-id for 'info registers', which can be used for querying other
hmp commands.

Signed-off-by: Yi Wang <wang.y...@zte.com.cn>
Signed-off-by: Yun Liu <liu.y...@zte.com.cn>
---
 target/i386/helper.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/target/i386/helper.c b/target/i386/helper.c
index f63eb3d..a52f300 100644
--- a/target/i386/helper.c
+++ b/target/i386/helper.c
@@ -416,6 +416,14 @@ void x86_cpu_dump_state(CPUState *cs, FILE *f, 
fprintf_function cpu_fprintf,
 int eflags, i, nb;
 char cc_op_name[32];
 static const char *seg_name[6] = { "ES", "CS", "SS", "DS", "FS", "GS" };
+APICCommonState *s = APIC_COMMON(cpu->apic_state);
+
+if (!s) {
+cpu_fprintf(f, "local apic state not available\n");
+return;
+}
+cpu_fprintf(f, "(socket-id:%d core-id:%d thread-id:%d apic-id:%d)\n",
+cpu->socket_id, cpu->core_id, cpu->thread_id, s->id);
 
 eflags = cpu_compute_eflags(env);
 #ifdef TARGET_X86_64
-- 
1.8.3.1





[Qemu-devel] [PATCH v2 0/2] hmp: support querying lapic through apic-id for 'info lapic'

2017-07-26 Thread Yi Wang
This series add support querying local apic through apic-id for 'info
lapic'.
As cpu_index will not be used afterwards, so extend 'info registers'
firstly to get apic-id through monitor commands.

v1 -> v2:
 * PATCH 01: Make the code simpler [Igor]
 * PATCH 02: use cpu_by_arch_id() to obtain CPU [Eduardo]

Yi Wang (2):
  hmp: dump ids including socket-id, core-id and so on for 'info registers'
  hmp: allow apic-id for "info lapic"

 hmp-commands-info.hx  |  7 ---
 include/qom/cpu.h | 10 ++
 qom/cpu.c | 11 ---
 target/i386/helper.c  |  8 
 target/i386/monitor.c | 10 +-
 5 files changed, 39 insertions(+), 7 deletions(-)




[Qemu-devel] [PATCH v2 2/2] hmp: allow apic-id for "info lapic"

2017-07-26 Thread Yi Wang
Add [apic-id] support for hmp command "info lapic", which is
useful when debugging ipi and so on. Current behavior is not
changed when the parameter isn't specified.

Signed-off-by: Yi Wang <wang.y...@zte.com.cn>
Signed-off-by: Yun Liu <liu.y...@zte.com.cn>
Signed-off-by: Eduardo Habkost <ehabk...@redhat.com>
---
 hmp-commands-info.hx  |  7 ---
 include/qom/cpu.h | 10 ++
 qom/cpu.c | 11 ---
 target/i386/monitor.c | 10 +-
 4 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index d9df238..4ab7fce 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -115,9 +115,10 @@ ETEXI
 #if defined(TARGET_I386)
 {
 .name   = "lapic",
-.args_type  = "",
-.params = "",
-.help   = "show local apic state",
+.args_type  = "apic-id:i?",
+.params = "[apic-id]",
+.help   = "show local apic state (apic-id: local apic to read, 
default is which of current CPU)",
+
 .cmd= hmp_info_local_apic,
 },
 #endif
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 25eefea..b7ac949 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -755,6 +755,16 @@ CPUState *qemu_get_cpu(int index);
 bool cpu_exists(int64_t id);
 
 /**
+ * cpu_by_arch_id:
+ * @id: Guest-exposed CPU ID of the CPU to obtain.
+ *
+ * Get a CPU with matching @id.
+ *
+ * Returns: The CPU or %NULL if there is no matching CPU.
+ */
+CPUState *cpu_by_arch_id(int64_t id);
+
+/**
  * cpu_throttle_set:
  * @new_throttle_pct: Percent of sleep time. Valid range is 1 to 99.
  *
diff --git a/qom/cpu.c b/qom/cpu.c
index 4f38db0..e6210d5 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -34,7 +34,7 @@
 
 CPUInterruptHandler cpu_interrupt_handler;
 
-bool cpu_exists(int64_t id)
+CPUState *cpu_by_arch_id(int64_t id)
 {
 CPUState *cpu;
 
@@ -42,10 +42,15 @@ bool cpu_exists(int64_t id)
 CPUClass *cc = CPU_GET_CLASS(cpu);
 
 if (cc->get_arch_id(cpu) == id) {
-return true;
+return cpu;
 }
 }
-return false;
+return NULL;
+}
+
+bool cpu_exists(int64_t id)
+{
+return !!cpu_by_arch_id(id);
 }
 
 CPUState *cpu_generic_init(const char *typename, const char *cpu_model)
diff --git a/target/i386/monitor.c b/target/i386/monitor.c
index 77ead60..fe7d57b 100644
--- a/target/i386/monitor.c
+++ b/target/i386/monitor.c
@@ -632,7 +632,15 @@ const MonitorDef *target_monitor_defs(void)
 
 void hmp_info_local_apic(Monitor *mon, const QDict *qdict)
 {
-CPUState *cs = mon_get_cpu();
+CPUState *cs;
+
+if (qdict_haskey(qdict, "apic-id")) {
+int id = qdict_get_try_int(qdict, "apic-id", 0);
+cs = cpu_by_arch_id(id);
+} else {
+cs = mon_get_cpu();
+}
+
 
 if (!cs) {
 monitor_printf(mon, "No CPU available\n");
-- 
1.8.3.1





[Qemu-devel] [PATCH 2/2] [PATCH] hmp: allow apic-id for "info lapic"

2017-07-21 Thread Yi Wang
Add [apic-id] support for hmp command "info lapic", which is
useful when debugging ipi and so on. Current behavior is not
changed when the parameter isn't specified.

Signed-off-by: Yi Wang <wang.y...@zte.com.cn>
Signed-off-by: Yun Liu <liu.y...@zte.com.cn>
---
 hmp-commands-info.hx  |  6 +++---
 target/i386/cpu.h | 10 ++
 target/i386/helper.c  | 16 
 target/i386/monitor.c |  9 -
 4 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index d9df238..00623df 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -115,9 +115,9 @@ ETEXI
 #if defined(TARGET_I386)
 {
 .name   = "lapic",
-.args_type  = "",
-.params = "",
-.help   = "show local apic state",
+.args_type  = "apic-id:i?",
+.params = "[apic-id]",
+.help   = "show local apic state (apic-id: local apic to read, 
default is 0)",
 .cmd= hmp_info_local_apic,
 },
 #endif
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 31ad681..4da2ca2 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1712,6 +1712,16 @@ void enable_compat_apic_id_mode(void);
 #define APIC_DEFAULT_ADDRESS 0xfee0
 #define APIC_SPACE_SIZE  0x10
 
+/**
+ * x86_get_cpu_by_apic:
+ * @id: The apic-id of the specified CPU to obtain.
+ *
+ * Gets a CPU on which @id given of apic.
+ *
+ * Returns: The CPU or %NULL if there is no matching CPU.
+ */
+CPUState *x86_get_cpu_by_apic(int id);
+
 void x86_cpu_dump_local_apic_state(CPUState *cs, FILE *f,
fprintf_function cpu_fprintf, int flags);
 
diff --git a/target/i386/helper.c b/target/i386/helper.c
index fd4f1af..6972833 100644
--- a/target/i386/helper.c
+++ b/target/i386/helper.c
@@ -398,6 +398,22 @@ void x86_cpu_dump_local_apic_state(CPUState *cs, FILE *f,
 }
 cpu_fprintf(f, " PPR 0x%02x\n", apic_get_ppr(s));
 }
+
+CPUState *x86_get_cpu_by_apic(int id)
+{
+CPUState *cs;
+
+CPU_FOREACH(cs) {
+X86CPU *cpu = X86_CPU(cs);
+APICCommonState *s = APIC_COMMON(cpu->apic_state);
+if (id == s->id) {
+return cs;
+}
+}
+
+return NULL;
+}
+
 #else
 void x86_cpu_dump_local_apic_state(CPUState *cs, FILE *f,
fprintf_function cpu_fprintf, int flags)
diff --git a/target/i386/monitor.c b/target/i386/monitor.c
index 77ead60..e911a57 100644
--- a/target/i386/monitor.c
+++ b/target/i386/monitor.c
@@ -632,7 +632,14 @@ const MonitorDef *target_monitor_defs(void)
 
 void hmp_info_local_apic(Monitor *mon, const QDict *qdict)
 {
-CPUState *cs = mon_get_cpu();
+CPUState *cs;
+
+if (qdict_haskey(qdict, "apic-id")) {
+int id = qdict_get_try_int(qdict, "apic-id", 0);
+cs = x86_get_cpu_by_apic(id);
+} else {
+cs = mon_get_cpu();
+}
 
 if (!cs) {
 monitor_printf(mon, "No CPU available\n");
-- 
1.8.3.1





[Qemu-devel] [PATCH 1/2] [PATCH] hmp: dump ids including socket-id, core-id and so on for 'info registers'

2017-07-21 Thread Yi Wang
This patch add output of CPUs' socket-id, core-id, thread-id and
apic-id for 'info registers', which can be used for querying other
hmp commands.

Signed-off-by: Yi Wang <wang.y...@zte.com.cn>
Signed-off-by: Yun Liu <liu.y...@zte.com.cn>
---
 include/qom/cpu.h| 12 
 monitor.c|  1 +
 qom/cpu.c| 10 ++
 target/i386/cpu.c|  1 +
 target/i386/cpu.h|  1 +
 target/i386/helper.c | 13 +
 6 files changed, 38 insertions(+)

diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 25eefea..4717bd7 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -92,6 +92,7 @@ struct TranslationBlock;
  * CPUs can use the default implementation of this method. This method should
  * not be used by any callers other than the pre-1.0 virtio devices.
  * @memory_rw_debug: Callback for GDB memory access.
+ * @dump_ids: Callback for dumping ids.
  * @dump_state: Callback for dumping state.
  * @dump_statistics: Callback for dumping statistics.
  * @get_arch_id: Callback for getting architecture-dependent CPU ID.
@@ -156,6 +157,7 @@ typedef struct CPUClass {
 bool (*virtio_is_big_endian)(CPUState *cpu);
 int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
uint8_t *buf, int len, bool is_write);
+void (*dump_ids)(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf);
 void (*dump_state)(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf,
int flags);
 GuestPanicInformation* (*get_crash_info)(CPUState *cpu);
@@ -518,6 +520,16 @@ enum CPUDumpFlags {
 };
 
 /**
+ * cpu_dump_ids:
+ * @cpu: The CPU whose state is to be dumped.
+ * @f: File to dump to.
+ * @cpu_fprintf: Function to dump with.
+ *
+ * Dumps CPU socket-id, core-id, thread-id and apic-id.
+ */
+void cpu_dump_ids(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf);
+
+/**
  * cpu_dump_state:
  * @cpu: The CPU whose state is to be dumped.
  * @f: File to dump to.
diff --git a/monitor.c b/monitor.c
index 6d040e6..30f898c 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1085,6 +1085,7 @@ static void hmp_info_registers(Monitor *mon, const QDict 
*qdict)
 if (all_cpus) {
 CPU_FOREACH(cs) {
 monitor_printf(mon, "\nCPU#%d\n", cs->cpu_index);
+cpu_dump_ids(cs, (FILE *)mon, monitor_fprintf);
 cpu_dump_state(cs, (FILE *)mon, monitor_fprintf, CPU_DUMP_FPU);
 }
 } else {
diff --git a/qom/cpu.c b/qom/cpu.c
index 4f38db0..a9df661 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -242,6 +242,16 @@ GuestPanicInformation *cpu_get_crash_info(CPUState *cpu)
 return res;
 }
 
+void cpu_dump_ids(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf)
+{
+CPUClass *cc = CPU_GET_CLASS(cpu);
+
+if (cc->dump_ids) {
+cpu_synchronize_state(cpu);
+cc->dump_ids(cpu, f, cpu_fprintf);
+}
+}
+
 void cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf,
 int flags)
 {
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 0bbda76..0aa488f 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -4120,6 +4120,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, 
void *data)
 cc->do_interrupt = x86_cpu_do_interrupt;
 cc->cpu_exec_interrupt = x86_cpu_exec_interrupt;
 #endif
+cc->dump_ids = x86_cpu_dump_ids;
 cc->dump_state = x86_cpu_dump_state;
 cc->get_crash_info = x86_cpu_get_crash_info;
 cc->set_pc = x86_cpu_set_pc;
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 0518673..31ad681 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1316,6 +1316,7 @@ int x86_cpu_write_elf32_qemunote(WriteCoreDumpFunction f, 
CPUState *cpu,
 void x86_cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list,
 Error **errp);
 
+void x86_cpu_dump_ids(CPUState *cs, FILE *f, fprintf_function cpu_fprintf);
 void x86_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
 int flags);
 
diff --git a/target/i386/helper.c b/target/i386/helper.c
index f63eb3d..fd4f1af 100644
--- a/target/i386/helper.c
+++ b/target/i386/helper.c
@@ -408,6 +408,19 @@ void x86_cpu_dump_local_apic_state(CPUState *cs, FILE *f,
 #define DUMP_CODE_BYTES_TOTAL50
 #define DUMP_CODE_BYTES_BACKWARD 20
 
+void x86_cpu_dump_ids(CPUState *cs, FILE *f, fprintf_function cpu_fprintf)
+{
+X86CPU *cpu = X86_CPU(cs);
+APICCommonState *s = APIC_COMMON(cpu->apic_state);
+if (!s) {
+cpu_fprintf(f, "local apic state not available\n");
+return;
+}
+
+cpu_fprintf(f, "(socket-id:%d core-id:%d thread-id:%d apic-id:%d)\n",
+cpu->socket_id, cpu->core_id, cpu->thread_id, s->id);
+}
+
 void x86_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
 int flags)
 {
-- 
1.8.3.1





[Qemu-devel] [PATCH 0/2] hmp: support querying lapic through

2017-07-21 Thread Yi Wang
This series add support querying local apic through apic-id for 'info
lapic'.
As cpu_index will not be used afterwards, so extend 'info registers'
firstly to get apic-id through monitor commands.

Yi Wang (2):
  hmp: dump ids including socket-id, core-id and so on for 'info registers'
  hmp: allow apic-id for "info lapic"

 hmp-commands-info.hx  |  6 +++---
 include/qom/cpu.h | 12 
 monitor.c |  1 +
 qom/cpu.c | 10 ++
 target/i386/cpu.c |  1 +
 target/i386/cpu.h | 11 +++
 target/i386/helper.c  | 29 +
 target/i386/monitor.c |  9 -
 8 files changed, 75 insertions(+), 4 deletions(-)




[Qemu-devel] [PATCH v2] hmp: allow cpu index for "info lapic"

2017-07-18 Thread Yi Wang
Add [vcpu] index support for hmp command "info lapic", which is
useful when debugging ipi and so on. Current behavior is not
changed when the parameter isn't specified.

Signed-off-by: Yi Wang <wang.y...@zte.com.cn>
Signed-off-by: Yun Liu <liu.y...@zte.com.cn>
---
 hmp-commands-info.hx  | 6 +++---
 target/i386/monitor.c | 8 +++-
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index d9df238..c534b03 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -115,9 +115,9 @@ ETEXI
 #if defined(TARGET_I386)
 {
 .name   = "lapic",
-.args_type  = "",
-.params = "",
-.help   = "show local apic state",
+.args_type  = "vcpu:i?",
+.params = "[vcpu]",
+.help   = "show local apic state (vcpu: vCPU to read, default is 
0)",
 .cmd= hmp_info_local_apic,
 },
 #endif
diff --git a/target/i386/monitor.c b/target/i386/monitor.c
index 77ead60..813005e 100644
--- a/target/i386/monitor.c
+++ b/target/i386/monitor.c
@@ -632,8 +632,14 @@ const MonitorDef *target_monitor_defs(void)
 
 void hmp_info_local_apic(Monitor *mon, const QDict *qdict)
 {
-CPUState *cs = mon_get_cpu();
+CPUState *cs;
 
+if (qdict_haskey(qdict, "vcpu")) {
+int index = qdict_get_try_int(qdict, "vcpu", 0);
+cs = qemu_get_cpu(index);
+} else {
+cs = mon_get_cpu();
+}
 if (!cs) {
 monitor_printf(mon, "No CPU available\n");
 return;
-- 
1.8.3.1





[Qemu-devel] creating vm fails if maxMemory equals to memory, but hotplug same will success

2015-10-07 Thread Yi Wang
Hi, all
When I create a vm using virsh, it will fail if maxMemory(2G) equals
to memory(2G) in XML:
error: Failed to create domain from vm1.xml
error: internal error: process exited while connecting to monitor:
qemu-kvm: -msg timestamp=on: invalid value of -m option maxmem: memory
slots were specified but maximum memory size (0x8000) is equal to
the initial memory size (0x8000)

However, if I allocate 1G memory for the guest at boot time(maxMemory
is still 2G), and then hotplug 1G to it, and it will success! Now
total memory is 2G and it equals to maxMemory. Is this a bug? if so, I
would be happy to work on a patch to fix this. Please tell me how this
designs if this is not a bug.

Thanks a lot.

-- 
Best Regards
Yi Wang



Re: [Qemu-devel] [PATCH] savevm: create snapshot failed when id_str already exits

2015-03-12 Thread Yi Wang
How about this?

From 913cf2cd04167b7f6b892ac1ab405a617d886b97 Mon Sep 17 00:00:00 2001
From: Yi Wang up2w...@gmail.com
Date: Thu, 12 Mar 2015 22:54:42 +0800
Subject: [PATCH] savevm: create snapshot failed when id_str already exists

The command virsh create will fail in such condition: vm has two
disks: vda and vdb. vda has snapshot s1 with id 1, vdb doesn't have
s1 but has snapshot s2 with id 1。When we want to run command virsh
create s1, del_existing_snapshots() only deletes s1 in vda, and
bdrv_snapshot_create() tries to create vdb's snapshot s1 with id 1,
but id 1 alreay exists in vdb with name s2!

The simplest way is call find_new_snapshot_id() unconditionally.

Signed-off-by: Yi Wang up2w...@gmail.com
---
 block/qcow2-snapshot.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
index 5b3903c..cb00f56 100644
--- a/block/qcow2-snapshot.c
+++ b/block/qcow2-snapshot.c
@@ -351,10 +351,8 @@ int qcow2_snapshot_create(BlockDriverState *bs,
QEMUSnapshotInfo *sn_info)

 memset(sn, 0, sizeof(*sn));

-/* Generate an ID if it wasn't passed */
-if (sn_info-id_str[0] == '\0') {
-find_new_snapshot_id(bs, sn_info-id_str, sizeof(sn_info-id_str));
-}
+/* Generate an ID */
+find_new_snapshot_id(bs, sn_info-id_str, sizeof(sn_info-id_str));

 /* Check that the ID is unique */
 if (find_snapshot_by_id_and_name(bs, sn_info-id_str, NULL) = 0) {
-- 
1.9.5.msysgit.0


2015-03-11 20:57 GMT+08:00 Stefan Hajnoczi stefa...@gmail.com:
 On Tue, Mar 10, 2015 at 02:48:46PM +0100, Kevin Wolf wrote:
 Am 10.03.2015 um 14:28 hat Stefan Hajnoczi geschrieben:
  On Mon, Mar 09, 2015 at 09:32:47PM +0800, Yi Wang wrote:
   This will trigger the problem: vda has snapshot s1 with id 1, vdb
   doesn't have s1 but has snapshot s2 with id 1。When we want to run
   command virsh create s1, del_existing_snapshots() only deletes s1 in
   vda, and bdrv_snapshot_create() tries to create vdb's snapshot s1 with
   id 1, but id 1 alreay exists in vdb with name s2!
  
   This shows the condition:
   # qemu-img snapshot -l win7.img.1
   Snapshot list:
   ID TAG VM SIZE DATE VM CLOCK
   1 s1 534M 2015-03-09 10:28:54 00:03:54.504
  
   # qemu-img snapshot -l win7.append
   Snapshot list:
   ID TAG VM SIZE DATE VM CLOCK
   1 s2 0 2015-03-05 10:29:21 00:00:00.000
  
   # virsh snapshot-create-as win7 s1
   error: operation failed: Failed to take snapshot: Error while creating
   snapshot on 'drive-virtio-disk1'
 
  Then we've arrived at changing the behavior of 'savevm' so it always
  generates IDs.
 
  Kevin: What do you think about changing savevm semantics to always
  generate IDs?

 Sounds reasonable. We're free to set whatever ID we want.

 However, I wouldn't set id_str =  like in the patch below, but remove
 the check qcow2_snapshot_create() and call find_new_snapshot_id()
 unconditionally.

 Good idea!

 Yi: If you are happy with the approach Kevin suggested, please send a
 patch.

 Stefan



-- 
Best Regards
Yi Wang



Re: [Qemu-devel] [PATCH] savevm: create snapshot failed when id_str already exits

2015-03-09 Thread Yi Wang
This will trigger the problem: vda has snapshot s1 with id 1, vdb
doesn't have s1 but has snapshot s2 with id 1。When we want to run
command virsh create s1, del_existing_snapshots() only deletes s1 in
vda, and bdrv_snapshot_create() tries to create vdb's snapshot s1 with
id 1, but id 1 alreay exists in vdb with name s2!

This shows the condition:
# qemu-img snapshot -l win7.img.1
Snapshot list:
ID TAG VM SIZE DATE VM CLOCK
1 s1 534M 2015-03-09 10:28:54 00:03:54.504

# qemu-img snapshot -l win7.append
Snapshot list:
ID TAG VM SIZE DATE VM CLOCK
1 s2 0 2015-03-05 10:29:21 00:00:00.000

# virsh snapshot-create-as win7 s1
error: operation failed: Failed to take snapshot: Error while creating
snapshot on 'drive-virtio-disk1'

2015-03-06 23:50 GMT+08:00 Stefan Hajnoczi stefa...@redhat.com:
 On Fri, Mar 06, 2015 at 10:35:41PM +0800, Yi Wang wrote:
 Yeah, your method is better. But there is still a little problem.
 For example: vda has one snapshot with name s1 and id_str 1, vdb
 has two snapshots: first name s1 and id_str 2; second name s2
 and id_str 3. Error will occur when we want to create snapshot s1,
 because snapshot s1 with id_str 2 already exists in vdb.
 So what we only need to do is clearing id_str when name != NULL.

 How do you trigger that?

 I thought there is already code to prevent this problem.  If name=s1
 then the following code should delete the existing snapshot so it can be
 replaced:

   /* Delete old snapshots of the same name */
   if (name  del_existing_snapshots(mon, name)  0) {
   goto the_end;
   }

 diff --git a/savevm.c b/savevm.c
 index 08ec678..716d15a 100644
 --- a/savevm.c
 +++ b/savevm.c
 @@ -1123,6 +1123,14 @@ void do_savevm(Monitor *mon, const QDict *qdict)

 Please rebase onto qemu.git/master where do_savevm() has been renamed to
 hmp_savevm().

  if (bdrv_can_snapshot(bs1)) {
  /* Write VM state size only to the image that contains the 
 state */
  sn-vm_state_size = (bs == bs1 ? vm_state_size : 0);
 +
 +/* Images may have existing IDs so let the ID be
 autogenerated if the
 + * user specify a name.
 + */
 +if (name) {
 + sn-id_str[0] = '\0';
 +}
 +
  ret = bdrv_snapshot_create(bs1, sn);
  if (ret  0) {
  monitor_printf(mon, Error while creating snapshot on 
 '%s'\n,

 2015-03-06 1:40 GMT+08:00 Stefan Hajnoczi stefa...@redhat.com:
  On Thu, Mar 05, 2015 at 09:05:52PM +0800, Yi Wang wrote:
  Thanks for your reply and Happy Lantern Festival!
  I am afraid you misunderstood what I mean, maybe I didn't express
  clearly :-) My patch works in such case:
  Firstly vm has two disks:
  [root@fox-host vmimg]# virsh domblklist win7
  Target Source
  
  hdb /home/virtio_test.iso
  vda /home/vmimg/win7.img.1
  vdb /home/vmimg/win7.append
 
  Secondly first disk has one snapshot with id_str 1, and another disk
  has three snapshots with id_str 1, 2, 3.
  [root@fox-host vmimg]# qemu-img snapshot -l win7.img.1
  Snapshot list:
  ID TAG VM SIZE DATE VM CLOCK
  1 s1 0 2015-03-05 10:26:16 00:00:00.000
 
  [root@fox-host vmimg]# qemu-img snapshot -l win7.append
  Snapshot list:
  ID TAG VM SIZE DATE VM CLOCK
  1 s3 0 2015-03-05 10:29:21 00:00:00.000
  2 s1 0 2015-03-05 10:29:38 00:00:00.000
  3 s2 0 2015-03-05 10:30:49 00:00:00.000
 
  In this case, we will fail when create snapshot specifying a name,
  'cause id_str 2 already exists in disk vdb.
  [root@fox-host8 vmimg]# virsh snapshot-create-as win7-fox s4
  error: operation failed: Failed to take snapshot: Error while creating
  snapshot on 'drive-virtio-disk1'
 
  This means that name != NULL but it is still unnecessary to duplicate ID
  generation.
 
  Does this work?
 
  diff --git a/savevm.c b/savevm.c
  index 08ec678..e81e4aa 100644
  --- a/savevm.c
  +++ b/savevm.c
  @@ -1047,6 +1047,7 @@ void do_savevm(Monitor *mon, const QDict *qdict)
   QEMUFile *f;
   int saved_vm_running;
   uint64_t vm_state_size;
  +bool generate_ids = true;
   qemu_timeval tv;
   struct tm tm;
   const char *name = qdict_get_try_str(qdict, name);
  @@ -1088,6 +1089,7 @@ void do_savevm(Monitor *mon, const QDict *qdict)
   if (ret = 0) {
   pstrcpy(sn-name, sizeof(sn-name), old_sn-name);
   pstrcpy(sn-id_str, sizeof(sn-id_str), old_sn-id_str);
  +generate_ids = false;
   } else {
   pstrcpy(sn-name, sizeof(sn-name), name);
   }
  @@ -1123,6 +1125,14 @@ void do_savevm(Monitor *mon, const QDict *qdict)
   if (bdrv_can_snapshot(bs1)) {
   /* Write VM state size only to the image that contains the 
  state */
   sn-vm_state_size = (bs == bs1 ? vm_state_size : 0);
  +
  +/* Images may have existing IDs so let the ID be 
  autogenerated if the
  + * user did not specify a name

Re: [Qemu-devel] [PATCH] savevm: create snapshot failed when id_str already exits

2015-03-06 Thread Yi Wang
Yeah, your method is better. But there is still a little problem.
For example: vda has one snapshot with name s1 and id_str 1, vdb
has two snapshots: first name s1 and id_str 2; second name s2
and id_str 3. Error will occur when we want to create snapshot s1,
because snapshot s1 with id_str 2 already exists in vdb.
So what we only need to do is clearing id_str when name != NULL.

diff --git a/savevm.c b/savevm.c
index 08ec678..716d15a 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1123,6 +1123,14 @@ void do_savevm(Monitor *mon, const QDict *qdict)
 if (bdrv_can_snapshot(bs1)) {
 /* Write VM state size only to the image that contains the state */
 sn-vm_state_size = (bs == bs1 ? vm_state_size : 0);
+
+/* Images may have existing IDs so let the ID be
autogenerated if the
+ * user specify a name.
+ */
+if (name) {
+ sn-id_str[0] = '\0';
+}
+
 ret = bdrv_snapshot_create(bs1, sn);
 if (ret  0) {
 monitor_printf(mon, Error while creating snapshot on '%s'\n,

2015-03-06 1:40 GMT+08:00 Stefan Hajnoczi stefa...@redhat.com:
 On Thu, Mar 05, 2015 at 09:05:52PM +0800, Yi Wang wrote:
 Thanks for your reply and Happy Lantern Festival!
 I am afraid you misunderstood what I mean, maybe I didn't express
 clearly :-) My patch works in such case:
 Firstly vm has two disks:
 [root@fox-host vmimg]# virsh domblklist win7
 Target Source
 
 hdb /home/virtio_test.iso
 vda /home/vmimg/win7.img.1
 vdb /home/vmimg/win7.append

 Secondly first disk has one snapshot with id_str 1, and another disk
 has three snapshots with id_str 1, 2, 3.
 [root@fox-host vmimg]# qemu-img snapshot -l win7.img.1
 Snapshot list:
 ID TAG VM SIZE DATE VM CLOCK
 1 s1 0 2015-03-05 10:26:16 00:00:00.000

 [root@fox-host vmimg]# qemu-img snapshot -l win7.append
 Snapshot list:
 ID TAG VM SIZE DATE VM CLOCK
 1 s3 0 2015-03-05 10:29:21 00:00:00.000
 2 s1 0 2015-03-05 10:29:38 00:00:00.000
 3 s2 0 2015-03-05 10:30:49 00:00:00.000

 In this case, we will fail when create snapshot specifying a name,
 'cause id_str 2 already exists in disk vdb.
 [root@fox-host8 vmimg]# virsh snapshot-create-as win7-fox s4
 error: operation failed: Failed to take snapshot: Error while creating
 snapshot on 'drive-virtio-disk1'

 This means that name != NULL but it is still unnecessary to duplicate ID
 generation.

 Does this work?

 diff --git a/savevm.c b/savevm.c
 index 08ec678..e81e4aa 100644
 --- a/savevm.c
 +++ b/savevm.c
 @@ -1047,6 +1047,7 @@ void do_savevm(Monitor *mon, const QDict *qdict)
  QEMUFile *f;
  int saved_vm_running;
  uint64_t vm_state_size;
 +bool generate_ids = true;
  qemu_timeval tv;
  struct tm tm;
  const char *name = qdict_get_try_str(qdict, name);
 @@ -1088,6 +1089,7 @@ void do_savevm(Monitor *mon, const QDict *qdict)
  if (ret = 0) {
  pstrcpy(sn-name, sizeof(sn-name), old_sn-name);
  pstrcpy(sn-id_str, sizeof(sn-id_str), old_sn-id_str);
 +generate_ids = false;
  } else {
  pstrcpy(sn-name, sizeof(sn-name), name);
  }
 @@ -1123,6 +1125,14 @@ void do_savevm(Monitor *mon, const QDict *qdict)
  if (bdrv_can_snapshot(bs1)) {
  /* Write VM state size only to the image that contains the state 
 */
  sn-vm_state_size = (bs == bs1 ? vm_state_size : 0);
 +
 +/* Images may have existing IDs so let the ID be autogenerated 
 if the
 + * user did not specify a name.
 + */
 +if (generate_ids) {
 +sn-id_str[0] = '\0';
 +}
 +
  ret = bdrv_snapshot_create(bs1, sn);
  if (ret  0) {
  monitor_printf(mon, Error while creating snapshot on 
 '%s'\n,



-- 
Best Regards
Yi Wang



Re: [Qemu-devel] [PATCH] savevm: create snapshot failed when id_str already exits

2015-03-05 Thread Yi Wang
Thanks for your reply and Happy Lantern Festival!
I am afraid you misunderstood what I mean, maybe I didn't express
clearly :-) My patch works in such case:
Firstly vm has two disks:
[root@fox-host vmimg]# virsh domblklist win7
Target Source

hdb /home/virtio_test.iso
vda /home/vmimg/win7.img.1
vdb /home/vmimg/win7.append

Secondly first disk has one snapshot with id_str 1, and another disk
has three snapshots with id_str 1, 2, 3.
[root@fox-host vmimg]# qemu-img snapshot -l win7.img.1
Snapshot list:
ID TAG VM SIZE DATE VM CLOCK
1 s1 0 2015-03-05 10:26:16 00:00:00.000

[root@fox-host vmimg]# qemu-img snapshot -l win7.append
Snapshot list:
ID TAG VM SIZE DATE VM CLOCK
1 s3 0 2015-03-05 10:29:21 00:00:00.000
2 s1 0 2015-03-05 10:29:38 00:00:00.000
3 s2 0 2015-03-05 10:30:49 00:00:00.000

In this case, we will fail when create snapshot specifying a name,
'cause id_str 2 already exists in disk vdb.
[root@fox-host8 vmimg]# virsh snapshot-create-as win7-fox s4
error: operation failed: Failed to take snapshot: Error while creating
snapshot on 'drive-virtio-disk1'

2015-02-25 17:41 GMT+08:00 Stefan Hajnoczi stefa...@redhat.com:
 On Mon, Jan 12, 2015 at 01:12:41AM +0800, Yi Wang wrote:
 From b119164ba6715f53594facfc4d1022c198852e9d Mon Sep 17 00:00:00 2001
 From: Yi Wang up2w...@gmail.com
 Date: Mon, 12 Jan 2015 00:05:40 +0800
 Subject: [PATCH] savevm: create snapshot failed when id_str already exits

 Create snapshot failed in this case:
 1) vm has two or more qcow2 disks;
 2) the first disk has snapshot with id_str 1, and the second disk has
 snapshots with id_str 2 and 3, for example;
 3) create snapshot using virsh snapshot-create/snapshot-create-as will
 fail, 'cause id_str 2 has already existed in disk two.

 The reason is that do_savevm() didn't check id_str before create
 bdrv_snapshot_create(), and this patch fixed this.

 Signed-off-by: Yi Wang up2w...@gmail.com
 ---
  block/snapshot.c |   32 
  include/block/snapshot.h |1 +
  savevm.c |7 +++
  3 files changed, 40 insertions(+), 0 deletions(-)

 diff --git a/block/snapshot.c b/block/snapshot.c
 index 698e1a1..f2757ab 100644
 --- a/block/snapshot.c
 +++ b/block/snapshot.c
 @@ -66,6 +66,38 @@ int bdrv_snapshot_find(BlockDriverState *bs,
 QEMUSnapshotInfo *sn_info,
  return ret;
  }

 +int bdrv_snapshot_get_id_str(BlockDriverState *bs, QEMUSnapshotInfo 
 *sn_info)
 +{
 +QEMUSnapshotInfo *sn_tab, *sn;
 +int nb_sns, i, ret;
 +int max = 0, temp_max;
 +bool need_max = false;
 +
 +ret = -ENOENT;
 +nb_sns = bdrv_snapshot_list(bs, sn_tab);
 +if (nb_sns  0) {
 +return ret;
 +}
 +
 +for (i = 0; i  nb_sns; i++) {
 +sn = sn_tab[i];
 +temp_max = atoi(sn-id_str);
 +if (max  temp_max) {
 +max = temp_max;
 +}
 +if (!need_max  !strcmp(sn-id_str, sn_info-id_str)) {
 +need_max = true;
 +}
 +if (need_max) {
 +snprintf(sn_info-id_str, 128*sizeof(char), %d, max+1);
 +}
 +
 +}
 +g_free(sn_tab);
 +ret = 0;
 +return ret;
 +}
 +
  /**
   * Look up an internal snapshot by @id and @name.
   * @bs: block device to search
 diff --git a/include/block/snapshot.h b/include/block/snapshot.h
 index 770d9bb..047ed7b 100644
 --- a/include/block/snapshot.h
 +++ b/include/block/snapshot.h
 @@ -49,6 +49,7 @@ typedef struct QEMUSnapshotInfo {

  int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info,
 const char *name);
 +int bdrv_snapshot_get_id_str(BlockDriverState *bs, QEMUSnapshotInfo 
 *sn_info);
  bool bdrv_snapshot_find_by_id_and_name(BlockDriverState *bs,
 const char *id,
 const char *name,
 diff --git a/savevm.c b/savevm.c
 index 08ec678..f2edc13 100644
 --- a/savevm.c
 +++ b/savevm.c
 @@ -1123,6 +1123,13 @@ void do_savevm(Monitor *mon, const QDict *qdict)
  if (bdrv_can_snapshot(bs1)) {
  /* Write VM state size only to the image that contains the 
 state */
  sn-vm_state_size = (bs == bs1 ? vm_state_size : 0);
 +
 +/* To avoid sn-id_str already exists */
 +if (bdrv_snapshot_get_id_str(bs1, sn)  0) {
 +monitor_printf(mon, Error when get id str.\n);
 +goto the_end;
 +}
 +

 Does this solve the issue?

 /* Images may have existing IDs so let the ID be autogenerated if the
  * user did not specify a name.
  */
 if (!name) {
 sn-id_str[0] = '\0';
 }

 The effect is similar to your patch but it avoids duplicating the id_str
 generation.



-- 
Best Regards
Yi Wang



[Qemu-devel] [PATCH] savevm: create snapshot failed when id_str already exits

2015-01-11 Thread Yi Wang
From b119164ba6715f53594facfc4d1022c198852e9d Mon Sep 17 00:00:00 2001
From: Yi Wang up2w...@gmail.com
Date: Mon, 12 Jan 2015 00:05:40 +0800
Subject: [PATCH] savevm: create snapshot failed when id_str already exits

Create snapshot failed in this case:
1) vm has two or more qcow2 disks;
2) the first disk has snapshot with id_str 1, and the second disk has
snapshots with id_str 2 and 3, for example;
3) create snapshot using virsh snapshot-create/snapshot-create-as will
fail, 'cause id_str 2 has already existed in disk two.

The reason is that do_savevm() didn't check id_str before create
bdrv_snapshot_create(), and this patch fixed this.

Signed-off-by: Yi Wang up2w...@gmail.com
---
 block/snapshot.c |   32 
 include/block/snapshot.h |1 +
 savevm.c |7 +++
 3 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/block/snapshot.c b/block/snapshot.c
index 698e1a1..f2757ab 100644
--- a/block/snapshot.c
+++ b/block/snapshot.c
@@ -66,6 +66,38 @@ int bdrv_snapshot_find(BlockDriverState *bs,
QEMUSnapshotInfo *sn_info,
 return ret;
 }

+int bdrv_snapshot_get_id_str(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
+{
+QEMUSnapshotInfo *sn_tab, *sn;
+int nb_sns, i, ret;
+int max = 0, temp_max;
+bool need_max = false;
+
+ret = -ENOENT;
+nb_sns = bdrv_snapshot_list(bs, sn_tab);
+if (nb_sns  0) {
+return ret;
+}
+
+for (i = 0; i  nb_sns; i++) {
+sn = sn_tab[i];
+temp_max = atoi(sn-id_str);
+if (max  temp_max) {
+max = temp_max;
+}
+if (!need_max  !strcmp(sn-id_str, sn_info-id_str)) {
+need_max = true;
+}
+if (need_max) {
+snprintf(sn_info-id_str, 128*sizeof(char), %d, max+1);
+}
+
+}
+g_free(sn_tab);
+ret = 0;
+return ret;
+}
+
 /**
  * Look up an internal snapshot by @id and @name.
  * @bs: block device to search
diff --git a/include/block/snapshot.h b/include/block/snapshot.h
index 770d9bb..047ed7b 100644
--- a/include/block/snapshot.h
+++ b/include/block/snapshot.h
@@ -49,6 +49,7 @@ typedef struct QEMUSnapshotInfo {

 int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info,
const char *name);
+int bdrv_snapshot_get_id_str(BlockDriverState *bs, QEMUSnapshotInfo *sn_info);
 bool bdrv_snapshot_find_by_id_and_name(BlockDriverState *bs,
const char *id,
const char *name,
diff --git a/savevm.c b/savevm.c
index 08ec678..f2edc13 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1123,6 +1123,13 @@ void do_savevm(Monitor *mon, const QDict *qdict)
 if (bdrv_can_snapshot(bs1)) {
 /* Write VM state size only to the image that contains the state */
 sn-vm_state_size = (bs == bs1 ? vm_state_size : 0);
+
+/* To avoid sn-id_str already exists */
+if (bdrv_snapshot_get_id_str(bs1, sn)  0) {
+monitor_printf(mon, Error when get id str.\n);
+goto the_end;
+}
+
 ret = bdrv_snapshot_create(bs1, sn);
 if (ret  0) {
 monitor_printf(mon, Error while creating snapshot on '%s'\n,
-- 
1.7.1


-- 
Best Regards
Yi Wang