* [Qemu-devel] [PATCH] Modify qemu_opt_rename to realize renaming all items in opts
@ 2014-09-23 13:13 Jun Li
2014-09-23 16:47 ` Eric Blake
0 siblings, 1 reply; 3+ messages in thread
From: Jun Li @ 2014-09-23 13:13 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, juli, famz, Jun Li, stefanha
Add realization of rename all items in opts for qemu_opt_rename.
e.g:
When add bps twice in command line, need to rename all bps to
throttling.bps-total.
Signed-off-by: Jun Li <junmuzi@gmail.com>
---
This patch solved following bug:
Bug 1145586 - qemu-kvm will give strange hint when add bps twice for a drive
ref:https://bugzilla.redhat.com/show_bug.cgi?id=1145586
---
blockdev.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index b361fbb..7c39a06 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -536,10 +536,15 @@ static void qemu_opt_rename(QemuOpts *opts, const char *from, const char *to)
{
const char *value;
- value = qemu_opt_get(opts, from);
- if (value) {
- qemu_opt_set(opts, to, value);
- qemu_opt_unset(opts, from);
+ /* rename all items */
+ while (1) {
+ value = qemu_opt_get(opts, from);
+ if (value) {
+ qemu_opt_set(opts, to, value);
+ qemu_opt_unset(opts, from);
+ } else {
+ break;
+ }
}
}
--
1.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] Modify qemu_opt_rename to realize renaming all items in opts
2014-09-23 13:13 [Qemu-devel] [PATCH] Modify qemu_opt_rename to realize renaming all items in opts Jun Li
@ 2014-09-23 16:47 ` Eric Blake
2014-09-24 5:23 ` Jun Li
0 siblings, 1 reply; 3+ messages in thread
From: Eric Blake @ 2014-09-23 16:47 UTC (permalink / raw)
To: Jun Li, qemu-devel; +Cc: kwolf, famz, juli, stefanha
[-- Attachment #1: Type: text/plain, Size: 1635 bytes --]
On 09/23/2014 07:13 AM, Jun Li wrote:
> Add realization of rename all items in opts for qemu_opt_rename.
> e.g:
> When add bps twice in command line, need to rename all bps to
> throttling.bps-total.
>
> Signed-off-by: Jun Li <junmuzi@gmail.com>
> ---
> This patch solved following bug:
> Bug 1145586 - qemu-kvm will give strange hint when add bps twice for a drive
> ref:https://bugzilla.redhat.com/show_bug.cgi?id=1145586
Including that bug link in the commit message might be nice for someone
visiting this patch a year from now.
> ---
> blockdev.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/blockdev.c b/blockdev.c
> index b361fbb..7c39a06 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -536,10 +536,15 @@ static void qemu_opt_rename(QemuOpts *opts, const char *from, const char *to)
> {
> const char *value;
>
> - value = qemu_opt_get(opts, from);
> - if (value) {
> - qemu_opt_set(opts, to, value);
> - qemu_opt_unset(opts, from);
> + /* rename all items */
> + while (1) {
> + value = qemu_opt_get(opts, from);
Can't this just be written as:
while ((value = qemu_opt_get(opts, from))) {
> + if (value) {
> + qemu_opt_set(opts, to, value);
> + qemu_opt_unset(opts, from);
> + } else {
> + break;
> + }
and lose the if/else and break? But that's style, not functional, so:
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] Modify qemu_opt_rename to realize renaming all items in opts
2014-09-23 16:47 ` Eric Blake
@ 2014-09-24 5:23 ` Jun Li
0 siblings, 0 replies; 3+ messages in thread
From: Jun Li @ 2014-09-24 5:23 UTC (permalink / raw)
To: Eric Blake; +Cc: kwolf, famz, juli, qemu-devel, stefanha
On Tue, 09/23 10:47, Eric Blake wrote:
> On 09/23/2014 07:13 AM, Jun Li wrote:
> > Add realization of rename all items in opts for qemu_opt_rename.
> > e.g:
> > When add bps twice in command line, need to rename all bps to
> > throttling.bps-total.
> >
> > Signed-off-by: Jun Li <junmuzi@gmail.com>
> > ---
> > This patch solved following bug:
> > Bug 1145586 - qemu-kvm will give strange hint when add bps twice for a drive
> > ref:https://bugzilla.redhat.com/show_bug.cgi?id=1145586
>
> Including that bug link in the commit message might be nice for someone
> visiting this patch a year from now.
ok, got it.
>
> > ---
> > blockdev.c | 13 +++++++++----
> > 1 file changed, 9 insertions(+), 4 deletions(-)
> >
> > diff --git a/blockdev.c b/blockdev.c
> > index b361fbb..7c39a06 100644
> > --- a/blockdev.c
> > +++ b/blockdev.c
> > @@ -536,10 +536,15 @@ static void qemu_opt_rename(QemuOpts *opts, const char *from, const char *to)
> > {
> > const char *value;
> >
> > - value = qemu_opt_get(opts, from);
> > - if (value) {
> > - qemu_opt_set(opts, to, value);
> > - qemu_opt_unset(opts, from);
> > + /* rename all items */
> > + while (1) {
> > + value = qemu_opt_get(opts, from);
>
> Can't this just be written as:
>
> while ((value = qemu_opt_get(opts, from))) {
>
> > + if (value) {
> > + qemu_opt_set(opts, to, value);
> > + qemu_opt_unset(opts, from);
> > + } else {
> > + break;
> > + }
>
> and lose the if/else and break? But that's style, not functional, so:
>
> Reviewed-by: Eric Blake <eblake@redhat.com>
Thanks. I will submit a new version.
Best Regards,
Jun Li
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-09-24 5:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-23 13:13 [Qemu-devel] [PATCH] Modify qemu_opt_rename to realize renaming all items in opts Jun Li
2014-09-23 16:47 ` Eric Blake
2014-09-24 5:23 ` Jun Li
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.