Blob Blame Raw
From 5902165e0f08a265b0bb422f13e161bd4de37eb3 Mon Sep 17 00:00:00 2001
From: Max Reitz <mreitz@redhat.com>
Date: Tue, 7 Jan 2014 21:57:06 +0100
Subject: [PATCH 01/14] option: Add assigned flag to QEMUOptionParameter

RH-Author: Max Reitz <mreitz@redhat.com>
Message-id: <1389131839-12920-2-git-send-email-mreitz@redhat.com>
Patchwork-id: 56537
O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 01/14] option: Add assigned flag to QEMUOptionParameter
Bugzilla: 1033490
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
RH-Acked-by: Fam Zheng <famz@redhat.com>
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>

BZ: 1033490

Adds an "assigned" flag to QEMUOptionParameter which is cleared at the
beginning of parse_option_parameters and set on (successful)
set_option_parameter and set_option_parameter_int.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit d4ca092a423f1f853a99357bab01a168bb57d625)

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 include/qemu/option.h | 1 +
 util/qemu-option.c    | 9 +++++++++
 2 files changed, 10 insertions(+)

Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 include/qemu/option.h |    1 +
 util/qemu-option.c    |    9 +++++++++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/include/qemu/option.h b/include/qemu/option.h
index 96f70b6..5c0c6dd 100644
--- a/include/qemu/option.h
+++ b/include/qemu/option.h
@@ -46,6 +46,7 @@ typedef struct QEMUOptionParameter {
         char* s;
     } value;
     const char *help;
+    bool assigned;
 } QEMUOptionParameter;
 
 
diff --git a/util/qemu-option.c b/util/qemu-option.c
index 1cefbfe..2445406 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -275,6 +275,8 @@ int set_option_parameter(QEMUOptionParameter *list, const char *name,
         return -1;
     }
 
+    list->assigned = true;
+
     return 0;
 }
 
@@ -306,6 +308,8 @@ int set_option_parameter_int(QEMUOptionParameter *list, const char *name,
         return -1;
     }
 
+    list->assigned = true;
+
     return 0;
 }
 
@@ -397,6 +401,7 @@ QEMUOptionParameter *parse_option_parameters(const char *param,
     char value[256];
     char *param_delim, *value_delim;
     char next_delim;
+    int i;
 
     if (list == NULL) {
         return NULL;
@@ -406,6 +411,10 @@ QEMUOptionParameter *parse_option_parameters(const char *param,
         dest = allocated = append_option_parameters(NULL, list);
     }
 
+    for (i = 0; dest[i].name; i++) {
+        dest[i].assigned = false;
+    }
+
     while (*param) {
 
         // Find parameter name and value in the string
-- 
1.7.1