On Mon, Apr 04, 2016 at 03:20:24PM +0200, Pavel Hrdina wrote:
This effectively removes virDomainGraphicsListenSetAddress which was
used only to change the address of listen structure and possible change
the listen type. The new function will auto-expand the listens array
and add a new listen.
The old function was used on pre-allocated array of listens and in most
cases it only "add" a new listen. The two remaining uses can access the
listen structure directly.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/conf/domain_conf.c | 34 +++++++++++++++-------------------
src/conf/domain_conf.h | 6 +++---
src/libvirt_private.syms | 2 +-
src/qemu/qemu_command.c | 6 ++----
src/qemu/qemu_parse_command.c | 4 +++-
src/qemu/qemu_process.c | 15 +++++++--------
src/vbox/vbox_common.c | 3 +--
src/vmx/vmx.c | 2 +-
src/xenconfig/xen_common.c | 12 +++++-------
src/xenconfig/xen_sxpr.c | 4 ++--
src/xenconfig/xen_xl.c | 4 +---
11 files changed, 41 insertions(+), 51 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 42050b0..c79a432 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10741,7 +10741,7 @@ virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def,
/* There were no <listen> elements, so we can just
* directly set listenAddr as listens[0]->address */
if (listenAddr && def->nListens == 0 &&
- virDomainGraphicsListenSetAddress(def, 0, listenAddr, -1, true) < 0)
+ virDomainGraphicsListenAddAddress(def, 0, listenAddr) < 0)
goto error;
ret = 0;
@@ -23820,31 +23820,27 @@ virDomainGraphicsListenGetAddress(virDomainGraphicsDefPtr def,
size_t i)
}
-/* Make a copy of up to len characters of address, and store it in
- * listens[i].address. If setType is true, set the listen's type
- * to 'address', otherwise leave type alone. */
int
-virDomainGraphicsListenSetAddress(virDomainGraphicsDefPtr def,
- size_t i, const char *address,
- int len, bool setType)
+virDomainGraphicsListenAddAddress(virDomainGraphicsDefPtr def,
+ int pos,
I would go even further and delete the pos argument too.
Every single caller uses 0 and only calls it when def->nListens == 0.
+ const char *address)
{
- virDomainGraphicsListenDefPtr listenInfo
- = virDomainGraphicsGetListen(def, i, true);
+ virDomainGraphicsListenDef listen;
- if (!listenInfo)
- return -1;
+ memset(&listen, 0, sizeof(listen));
- if (setType)
- listenInfo->type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS;
+ listen.type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS;
- if (!address) {
- VIR_FREE(listenInfo->address);
- return 0;
- }
+ if (VIR_STRDUP(listen.address, address) < 0)
+ goto error;
+
+ if (VIR_INSERT_ELEMENT_COPY(def->listens, pos, def->nListens, listen) < 0)
This would become APPEND_ELEMENT_COPY.
ACK
Jan