On 11/25/2016 10:53 AM, Erik Skultety wrote:
On Mon, Nov 21, 2016 at 06:35:50PM -0500, John Ferlan wrote:
> Rather than have multiple bool values, create a single enum with bits
> representing what can be set.
>
> Signed-off-by: John Ferlan <jferlan(a)redhat.com>
> ---
> src/qemu/qemu_driver.c | 113 +++++++++++++++++++++++--------------------------
> 1 file changed, 54 insertions(+), 59 deletions(-)
>
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 87d219f..73b58d0 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -17338,34 +17338,38 @@ qemuDomainOpenGraphicsFD(virDomainPtr dom,
> return ret;
> }
>
> +typedef enum {
> + QEMU_BLOCK_IOTUNE_SET_BYTES = 1 << 0,
> + QEMU_BLOCK_IOTUNE_SET_IOPS = 1 << 1,
> + QEMU_BLOCK_IOTUNE_SET_BYTES_MAX = 1 << 2,
> + QEMU_BLOCK_IOTUNE_SET_IOPS_MAX = 1 << 3,
> + QEMU_BLOCK_IOTUNE_SET_SIZE_IOPS = 1 << 4,
> + QEMU_BLOCK_IOTUNE_SET_BYTES_MAX_LENGTH = 1 << 5,
> + QEMU_BLOCK_IOTUNE_SET_IOPS_MAX_LENGTH = 1 << 6,
> +} qemuBlockIoTuneSetFlags;
> +
>
> /* If the user didn't specify bytes limits, inherit previous values;
> * likewise if the user didn't specify iops limits. */
> static void
> qemuDomainSetBlockIoTuneDefaults(virDomainBlockIoTuneInfoPtr newinfo,
> virDomainBlockIoTuneInfoPtr oldinfo,
> - bool set_bytes,
> - bool set_iops,
> - bool set_bytes_max,
> - bool set_iops_max,
> - bool set_size_iops,
> - bool set_bytes_max_length,
> - bool set_iops_max_length)
> + qemuBlockIoTuneSetFlags set_flag)
Just a cosmetic "nit", I spent a few seconds looking at the name
"set_flag"
confusingly (probably 'cause it's Friday). Maybe something like
set_map|set_mask|mask|bitmap or something alike would sound better, but then,
who am I to judge with my history of 'brilliant' function naming :D.
I could go with set_mask, but mask has a different connotation for some.
It's not a bitmap and there are those that would say that a bitmap
should use the Bitmap functions (which would be overkill at this point).
Maybe a 'set_fields_flag' would be clearer? It's a flag to indicate a
grouping of (usually) 3 elements ({read|write|total}) were set, where
size_iops and group_name become the exception.
Unless someone else has a brilliant suggestion...
John
Patch looks good though, I'll leave it to you.
Erik