Re: [libvirt] [PATCH 2/3] openvswitch: Add utility functions for getting and setting Open vSwitch per-port data
On 10/01/2012 11:18 AM, Kyle Mestery wrote: Add utility functions for Open vSwitch to both save per-port data before a live migration, and restore the per-port data after a live migration. Signed-off-by: Kyle Mestery kmest...@cisco.com --- src/libvirt_private.syms| 2 ++ src/util/virnetdevopenvswitch.c | 70 + src/util/virnetdevopenvswitch.h | 6 3 files changed, 78 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index eebc52a..449744e 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1477,7 +1477,9 @@ virNetDevMacVLanVPortProfileRegisterCallback; # virnetdevopenvswitch.h virNetDevOpenvswitchAddPort; +virNetDevOpenvswitchGetMigrateData; virNetDevOpenvswitchRemovePort; +virNetDevOpenvswitchSetMigrateData; # virnetdevtap.h diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c index a6993b6..841f693 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -179,3 +179,73 @@ int virNetDevOpenvswitchRemovePort(const char *brname ATTRIBUTE_UNUSED, const ch virCommandFree(cmd); return ret; } + +/** + * virNetDevOpenvswitchGetMigrateData: + * @migrate: a pointer to store the data into, allocated by this function + * @ifname: name of the interface for which data is being migrated + * + * Allocates data to be migrated specific to Open vSwitch + * + * Returns 0 in case of success or -1 in case of failure + */ +int virNetDevOpenvswitchGetMigrateData(char **migrate, const char *ifname) +{ +virCommandPtr cmd = NULL; +int ret = 0; + +cmd = virCommandNewArgList(OVSVSCTL, --timeout=5, get, Interface, + ifname, external_ids:PortData, NULL); + +virCommandSetOutputBuffer(cmd, migrate); + +/* Run the command */ +if (virCommandRun(cmd, NULL) 0) { +virReportSystemError(VIR_ERR_INTERNAL_ERROR, + _(Unable to run command to get OVS port data for + interface %s), ifname); +ret = -1; +goto error; +} + +/* Wipeout the newline */ +(*migrate)[strlen(*migrate) - 1] = '\0'; + +error: +return ret; +} + +/** + * virNetDevOpenvswitchSetMigrateData: + * @migrate: the data which was transferred during migration + * @ifname: the name of the interface the data is associated with + * + * Repopulates OVS per-port data on destination host + * + * Returns 0 in case of success or -1 in case of failure + */ +int virNetDevOpenvswitchSetMigrateData(char *migrate, const char *ifname) +{ +virCommandPtr cmd = NULL; +int ret = 0; +virBufferPtr buf; + +if (VIR_ALLOC(buf) 0) { +ret = -1; +goto error; +} + +virBufferAsprintf(buf, external_ids:PortData=%s, migrate); + +cmd = virCommandNewArgList(OVSVSCTL, --timeout=5, set, Interface, ifname, + virBufferCurrentContent(buf), NULL); +/* Run the command */ +if ((ret = virCommandRun(cmd, NULL)) 0) { +virReportSystemError(VIR_ERR_INTERNAL_ERROR, + _(Unable to run command to set OVS port data for + interface %s), ifname); +} + +error: +return ret; +} diff --git a/src/util/virnetdevopenvswitch.h b/src/util/virnetdevopenvswitch.h index 7e5b618..147cd6f 100644 --- a/src/util/virnetdevopenvswitch.h +++ b/src/util/virnetdevopenvswitch.h @@ -42,4 +42,10 @@ int virNetDevOpenvswitchAddPort(const char *brname, int virNetDevOpenvswitchRemovePort(const char *brname, const char *ifname) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; +int virNetDevOpenvswitchGetMigrateData(char **migrate, const char *ifname) +ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; + +int virNetDevOpenvswitchSetMigrateData(char *migrate, const char *ifname) +ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; + #endif /* __VIR_NETDEV_OPENVSWITCH_H__ */ ACK, but I'm going to resubmit it rebased on the new 1/3. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/3] openvswitch: Add utility functions for getting and setting Open vSwitch per-port data
Add utility functions for Open vSwitch to both save per-port data before a live migration, and restore the per-port data after a live migration. Signed-off-by: Kyle Mestery kmest...@cisco.com --- src/libvirt_private.syms| 2 ++ src/util/virnetdevopenvswitch.c | 70 + src/util/virnetdevopenvswitch.h | 6 3 files changed, 78 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index eebc52a..449744e 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1477,7 +1477,9 @@ virNetDevMacVLanVPortProfileRegisterCallback; # virnetdevopenvswitch.h virNetDevOpenvswitchAddPort; +virNetDevOpenvswitchGetMigrateData; virNetDevOpenvswitchRemovePort; +virNetDevOpenvswitchSetMigrateData; # virnetdevtap.h diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c index a6993b6..841f693 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -179,3 +179,73 @@ int virNetDevOpenvswitchRemovePort(const char *brname ATTRIBUTE_UNUSED, const ch virCommandFree(cmd); return ret; } + +/** + * virNetDevOpenvswitchGetMigrateData: + * @migrate: a pointer to store the data into, allocated by this function + * @ifname: name of the interface for which data is being migrated + * + * Allocates data to be migrated specific to Open vSwitch + * + * Returns 0 in case of success or -1 in case of failure + */ +int virNetDevOpenvswitchGetMigrateData(char **migrate, const char *ifname) +{ +virCommandPtr cmd = NULL; +int ret = 0; + +cmd = virCommandNewArgList(OVSVSCTL, --timeout=5, get, Interface, + ifname, external_ids:PortData, NULL); + +virCommandSetOutputBuffer(cmd, migrate); + +/* Run the command */ +if (virCommandRun(cmd, NULL) 0) { +virReportSystemError(VIR_ERR_INTERNAL_ERROR, + _(Unable to run command to get OVS port data for + interface %s), ifname); +ret = -1; +goto error; +} + +/* Wipeout the newline */ +(*migrate)[strlen(*migrate) - 1] = '\0'; + +error: +return ret; +} + +/** + * virNetDevOpenvswitchSetMigrateData: + * @migrate: the data which was transferred during migration + * @ifname: the name of the interface the data is associated with + * + * Repopulates OVS per-port data on destination host + * + * Returns 0 in case of success or -1 in case of failure + */ +int virNetDevOpenvswitchSetMigrateData(char *migrate, const char *ifname) +{ +virCommandPtr cmd = NULL; +int ret = 0; +virBufferPtr buf; + +if (VIR_ALLOC(buf) 0) { +ret = -1; +goto error; +} + +virBufferAsprintf(buf, external_ids:PortData=%s, migrate); + +cmd = virCommandNewArgList(OVSVSCTL, --timeout=5, set, Interface, ifname, + virBufferCurrentContent(buf), NULL); +/* Run the command */ +if ((ret = virCommandRun(cmd, NULL)) 0) { +virReportSystemError(VIR_ERR_INTERNAL_ERROR, + _(Unable to run command to set OVS port data for + interface %s), ifname); +} + +error: +return ret; +} diff --git a/src/util/virnetdevopenvswitch.h b/src/util/virnetdevopenvswitch.h index 7e5b618..147cd6f 100644 --- a/src/util/virnetdevopenvswitch.h +++ b/src/util/virnetdevopenvswitch.h @@ -42,4 +42,10 @@ int virNetDevOpenvswitchAddPort(const char *brname, int virNetDevOpenvswitchRemovePort(const char *brname, const char *ifname) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; +int virNetDevOpenvswitchGetMigrateData(char **migrate, const char *ifname) +ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; + +int virNetDevOpenvswitchSetMigrateData(char *migrate, const char *ifname) +ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; + #endif /* __VIR_NETDEV_OPENVSWITCH_H__ */ -- 1.7.11.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/3] openvswitch: Add utility functions for getting and setting Open vSwitch per-port data
On 09/21/2012 05:16 PM, Kyle Mestery wrote: Add utility functions for Open vSwitch to both save per-port data before a live migration, and restore the per-port data after a live migration. Signed-off-by: Kyle Mestery kmest...@cisco.com --- src/libvirt_private.syms| 2 ++ src/util/virnetdevopenvswitch.c | 70 + src/util/virnetdevopenvswitch.h | 6 3 files changed, 78 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 0b6068d..54c591b 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1479,7 +1479,9 @@ virNetDevMacVLanVPortProfileRegisterCallback; # virnetdevopenvswitch.h virNetDevOpenvswitchAddPort; +virNetDevOpenvswitchGetMigrateData; virNetDevOpenvswitchRemovePort; +virNetDevOpenvswitchSetMigrateData; # virnetdevtap.h diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c index a6993b6..c30cbaa 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -179,3 +179,73 @@ int virNetDevOpenvswitchRemovePort(const char *brname ATTRIBUTE_UNUSED, const ch virCommandFree(cmd); return ret; } + +/** + * virNetDevOpenvswitchGetMigrateData: + * @migrate: a pointer to store the data into, allocated by this function + * @ifname: name of the interface for which data is being migrated + * + * Allocates data to be migrated specific to Open vSwitch + * + * Returns 0 in case of success or -1 in case of failure + */ +int virNetDevOpenvswitchGetMigrateData(char **migrate, const char *ifname) +{ +virCommandPtr cmd = NULL; +int ret = 0; + +cmd = virCommandNewArgList(OVSVSCTL, get, Interface, + ifname, external_ids:PortData, NULL); + +virCommandSetOutputBuffer(cmd, migrate); + +/* Run the command */ +if (virCommandRun(cmd, NULL) 0) { +virReportSystemError(VIR_ERR_INTERNAL_ERROR, + _(Unable to run command to get OVS port data for + interface %s), ifname); +ret = -1; +goto error; +} + +/* Wipeout the newline */ +(*migrate)[strlen(*migrate) - 1] = '\0'; + +error: +return ret; +} + +/** + * virNetDevOpenvswitchSetMigrateData: + * @migrate: the data which was transferred during migration + * @ifname: the name of the interface the data is associated with + * + * Repopulates OVS per-port data on destination host + * + * Returns 0 in case of success or -1 in case of failure + */ +int virNetDevOpenvswitchSetMigrateData(char *migrate, const char *ifname) +{ +virCommandPtr cmd = NULL; +int ret = 0; +virBufferPtr buf; + +if (VIR_ALLOC(buf) 0) { +ret = -1; +goto error; +} + +virBufferAsprintf(buf, external_ids:PortData=%s, migrate); + +cmd = virCommandNewArgList(OVSVSCTL, set, Interface, ifname, + virBufferCurrentContent(buf), NULL); You need to add the --timeout=5 option as I did for add-port and del-port, to avoid an infinite wait when ovs-vswitchd isn't running. ACK with that change. +/* Run the command */ +if ((ret = virCommandRun(cmd, NULL)) 0) { +virReportSystemError(VIR_ERR_INTERNAL_ERROR, + _(Unable to run command to set OVS port data for + interface %s), ifname); +} + +error: +return ret; +} diff --git a/src/util/virnetdevopenvswitch.h b/src/util/virnetdevopenvswitch.h index 7e5b618..147cd6f 100644 --- a/src/util/virnetdevopenvswitch.h +++ b/src/util/virnetdevopenvswitch.h @@ -42,4 +42,10 @@ int virNetDevOpenvswitchAddPort(const char *brname, int virNetDevOpenvswitchRemovePort(const char *brname, const char *ifname) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; +int virNetDevOpenvswitchGetMigrateData(char **migrate, const char *ifname) +ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; + +int virNetDevOpenvswitchSetMigrateData(char *migrate, const char *ifname) +ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; + #endif /* __VIR_NETDEV_OPENVSWITCH_H__ */ -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/3] openvswitch: Add utility functions for getting and setting Open vSwitch per-port data
Add utility functions for Open vSwitch to both save per-port data before a live migration, and restore the per-port data after a live migration. Signed-off-by: Kyle Mestery kmest...@cisco.com --- src/libvirt_private.syms| 2 ++ src/util/virnetdevopenvswitch.c | 70 + src/util/virnetdevopenvswitch.h | 6 3 files changed, 78 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 0b6068d..54c591b 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1479,7 +1479,9 @@ virNetDevMacVLanVPortProfileRegisterCallback; # virnetdevopenvswitch.h virNetDevOpenvswitchAddPort; +virNetDevOpenvswitchGetMigrateData; virNetDevOpenvswitchRemovePort; +virNetDevOpenvswitchSetMigrateData; # virnetdevtap.h diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c index a6993b6..c30cbaa 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -179,3 +179,73 @@ int virNetDevOpenvswitchRemovePort(const char *brname ATTRIBUTE_UNUSED, const ch virCommandFree(cmd); return ret; } + +/** + * virNetDevOpenvswitchGetMigrateData: + * @migrate: a pointer to store the data into, allocated by this function + * @ifname: name of the interface for which data is being migrated + * + * Allocates data to be migrated specific to Open vSwitch + * + * Returns 0 in case of success or -1 in case of failure + */ +int virNetDevOpenvswitchGetMigrateData(char **migrate, const char *ifname) +{ +virCommandPtr cmd = NULL; +int ret = 0; + +cmd = virCommandNewArgList(OVSVSCTL, get, Interface, + ifname, external_ids:PortData, NULL); + +virCommandSetOutputBuffer(cmd, migrate); + +/* Run the command */ +if (virCommandRun(cmd, NULL) 0) { +virReportSystemError(VIR_ERR_INTERNAL_ERROR, + _(Unable to run command to get OVS port data for + interface %s), ifname); +ret = -1; +goto error; +} + +/* Wipeout the newline */ +(*migrate)[strlen(*migrate) - 1] = '\0'; + +error: +return ret; +} + +/** + * virNetDevOpenvswitchSetMigrateData: + * @migrate: the data which was transferred during migration + * @ifname: the name of the interface the data is associated with + * + * Repopulates OVS per-port data on destination host + * + * Returns 0 in case of success or -1 in case of failure + */ +int virNetDevOpenvswitchSetMigrateData(char *migrate, const char *ifname) +{ +virCommandPtr cmd = NULL; +int ret = 0; +virBufferPtr buf; + +if (VIR_ALLOC(buf) 0) { +ret = -1; +goto error; +} + +virBufferAsprintf(buf, external_ids:PortData=%s, migrate); + +cmd = virCommandNewArgList(OVSVSCTL, set, Interface, ifname, + virBufferCurrentContent(buf), NULL); +/* Run the command */ +if ((ret = virCommandRun(cmd, NULL)) 0) { +virReportSystemError(VIR_ERR_INTERNAL_ERROR, + _(Unable to run command to set OVS port data for + interface %s), ifname); +} + +error: +return ret; +} diff --git a/src/util/virnetdevopenvswitch.h b/src/util/virnetdevopenvswitch.h index 7e5b618..147cd6f 100644 --- a/src/util/virnetdevopenvswitch.h +++ b/src/util/virnetdevopenvswitch.h @@ -42,4 +42,10 @@ int virNetDevOpenvswitchAddPort(const char *brname, int virNetDevOpenvswitchRemovePort(const char *brname, const char *ifname) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; +int virNetDevOpenvswitchGetMigrateData(char **migrate, const char *ifname) +ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; + +int virNetDevOpenvswitchSetMigrateData(char *migrate, const char *ifname) +ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; + #endif /* __VIR_NETDEV_OPENVSWITCH_H__ */ -- 1.7.11.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list