[Libvirt-cim] [PATCH] Use Qumranet's OUI for KVM guests instead of using Xensource's
Richard Maciel
rmaciel at linux.vnet.ibm.com
Thu Sep 3 22:16:43 UTC 2009
+1
On 09/03/2009 04:53 PM, Kaitlin Rupert wrote:
> # HG changeset patch
> # User Kaitlin Rupert<karupert at us.ibm.com>
> # Date 1252007567 25200
> # Node ID 234141bf7f0368531c884334b1da5b94cc038758
> # Parent 9c8eb2dfae84ed67999657d8f238a8bd777e1c36
> Use Qumranet's OUI for KVM guests instead of using Xensource's.
>
> Signed-off-by: Kaitlin Rupert<karupert at us.ibm.com>
>
> diff -r 9c8eb2dfae84 -r 234141bf7f03 src/Virt_VirtualSystemManagementService.c
> --- a/src/Virt_VirtualSystemManagementService.c Tue Sep 01 11:34:21 2009 -0700
> +++ b/src/Virt_VirtualSystemManagementService.c Thu Sep 03 12:52:47 2009 -0700
> @@ -57,7 +57,8 @@
>
> #include "config.h"
>
> -#define DEFAULT_MAC_PREFIX "00:16:3e"
> +#define XEN_MAC_PREFIX "00:16:3e"
> +#define KVM_MAC_PREFIX "00:1A:4A"
> #define DEFAULT_XEN_WEIGHT 1024
> #define BRIDGE_TYPE "bridge"
> #define NETWORK_TYPE "network"
> @@ -530,7 +531,7 @@
> return poolid;
> }
>
> -static const char *_net_rand_mac(void)
> +static const char *_net_rand_mac(const CMPIObjectPath *ref)
> {
> int r;
> int ret;
> @@ -540,6 +541,8 @@
> CMPIString *str = NULL;
> CMPIStatus status;
> struct timeval curr_time;
> + const char *mac_prefix = NULL;
> + char *cn_prefix = NULL;
>
> ret = gettimeofday(&curr_time, NULL);
> if (ret != 0)
> @@ -549,9 +552,18 @@
> s = curr_time.tv_usec;
> r = rand_r(&s);
>
> + cn_prefix = class_prefix_name(CLASSNAME(ref));
> +
> + if (STREQ(cn_prefix, "KVM"))
> + mac_prefix = KVM_MAC_PREFIX;
> + else
> + mac_prefix = XEN_MAC_PREFIX;
> +
> + free(cn_prefix);
> +
> ret = asprintf(&mac,
> "%s:%02x:%02x:%02x",
> - DEFAULT_MAC_PREFIX,
> + mac_prefix,
> r& 0xFF,
> (r& 0xFF00)>> 8,
> (r& 0xFF0000)>> 16);
> @@ -646,9 +658,16 @@
> const char *val = NULL;
> const char *msg = NULL;
> char *network = NULL;
> + CMPIObjectPath *op = NULL;
> +
> + op = CMGetObjectPath(inst, NULL);
> + if (op == NULL) {
> + msg = "Unable to determine classname of NetRASD";
> + goto out;
> + }
>
> if (cu_get_str_prop(inst, "Address",&val) != CMPI_RC_OK) {
> - val = _net_rand_mac();
> + val = _net_rand_mac(op);
> if (val == NULL) {
> msg = "Unable to generate a MAC address";
> goto out;
> @@ -1379,7 +1398,7 @@
> free((*domain)->dev_net->dev.net.mac);
> (*domain)->dev_net->dev.net.mac = NULL;
>
> - mac = _net_rand_mac();
> + mac = _net_rand_mac(ref);
> if (mac == NULL) {
> cu_statusf(_BROKER,&s,
> CMPI_RC_ERR_INVALID_PARAMETER,
>
> _______________________________________________
> Libvirt-cim mailing list
> Libvirt-cim at redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-cim
--
Richard Maciel, MSc
IBM Linux Technology Center
rmaciel at linux.vnet.ibm.com
More information about the Libvirt-cim
mailing list