Re: [Libvir] [PATCH]Change MAC address to case insensitive
On Wed, Feb 27, 2008 at 02:27:30PM +0900, S.Sakamoto wrote: OK, try this patch. I tried this patch. It works fine to me. Yes, the patch works for me too. I'll commit this end of today unless anyone objects. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [Libvir] [PATCH]Change MAC address to case insensitive
This patch has been committed now. Thanks for your contribution to libvirt. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[Libvir] [PATCH]Change MAC address to case insensitive
Hi, xenXMDomainAttachDevice and xenXMDomainDetachDevice treats case sensitve for MAC address of stopping domain. This patch changes from case sensitive to case insensitive. Thanks, Shigeki Sakamoto. Index: src/xm_internal.c === RCS file: /data/cvs/libvirt/src/xm_internal.c,v retrieving revision 1.64 diff -u -p -r1.64 xm_internal.c --- src/xm_internal.c 20 Feb 2008 15:29:13 - 1.64 +++ src/xm_internal.c 26 Feb 2008 06:40:57 - @@ -2812,7 +2812,7 @@ xenXMAttachInterface(virDomainPtr domain key = nextkey; } -if (!(strcmp(dommac, (const char *) mac))) { +if (!(strcasecmp(dommac, (const char *) mac))) { if (autoassign) { free(mac); mac = NULL; @@ -3087,7 +3087,7 @@ xenXMDomainDetachDevice(virDomainPtr dom mac = nextmac; } -if (!(strcmp(dommac, (const char *) key))) +if (!(strcasecmp(dommac, (const char *) key))) break; } skip: -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [Libvir] [PATCH]Change MAC address to case insensitive
I'll apply this today (using our STRCASEEQ macros) if no one else objects. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [Libvir] [PATCH]Change MAC address to case insensitive
Richard W.M. Jones [EMAIL PROTECTED] wrote: I'll apply this today (using our STRCASEEQ macros) if no one else objects. Hi, What do you think about using a MAC-address-specific comparison function? I.e., one that is not only case-independent, but that also knows leading zeros are unnecessary? i.e., it would admit that these two match: 00:0A:FF:3A:00:09 0:a:ff:3a:0:9 That would be a little more user friendly. In any case, even if we stick with simply case-ignoring, I suggest we give it a name, like macCompare and use it consistently. There's at least one other MAC comparison: virsh.c currently uses xmlStrcasecmp in cmdDetachInterface: diff_mac = xmlStrcasecmp(tmp_mac, BAD_CAST mac); -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [Libvir] [PATCH]Change MAC address to case insensitive
On Tue, Feb 26, 2008 at 12:13:43PM +0100, Jim Meyering wrote: Richard W.M. Jones [EMAIL PROTECTED] wrote: I'll apply this today (using our STRCASEEQ macros) if no one else objects. Hi, What do you think about using a MAC-address-specific comparison function? I.e., one that is not only case-independent, but that also knows leading zeros are unnecessary? i.e., it would admit that these two match: 00:0A:FF:3A:00:09 0:a:ff:3a:0:9 That would be a little more user friendly. Yes, we should add a helper function for comparing mac addresses for equality. Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=| -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [Libvir] [PATCH]Change MAC address to case insensitive
On Tue, Feb 26, 2008 at 12:54:15PM +, Daniel P. Berrange wrote: On Tue, Feb 26, 2008 at 12:13:43PM +0100, Jim Meyering wrote: Richard W.M. Jones [EMAIL PROTECTED] wrote: I'll apply this today (using our STRCASEEQ macros) if no one else objects. Hi, What do you think about using a MAC-address-specific comparison function? I.e., one that is not only case-independent, but that also knows leading zeros are unnecessary? i.e., it would admit that these two match: 00:0A:FF:3A:00:09 0:a:ff:3a:0:9 That would be a little more user friendly. Yes, we should add a helper function for comparing mac addresses for equality. OK, try this patch. Jim, not sure I understood to full complexities of making static linking work without duplicate symbols, so this patch may be wrong in that regard. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v Index: src/internal.h === RCS file: /data/cvs/libvirt/src/internal.h,v retrieving revision 1.63 diff -u -r1.63 internal.h --- src/internal.h 20 Feb 2008 15:06:53 - 1.63 +++ src/internal.h 26 Feb 2008 13:10:46 - @@ -54,7 +54,6 @@ #define STRNEQLEN(a,b,n) (strncmp((a),(b),(n)) != 0) #define STRCASENEQLEN(a,b,n) (strncasecmp((a),(b),(n)) != 0) - /* If configured with --enable-debug=yes then library calls * are printed to stderr for debugging. */ Index: src/libvirt_sym.version === RCS file: /data/cvs/libvirt/src/libvirt_sym.version,v retrieving revision 1.36 diff -u -r1.36 libvirt_sym.version --- src/libvirt_sym.version 21 Feb 2008 03:53:03 - 1.36 +++ src/libvirt_sym.version 26 Feb 2008 13:10:46 - @@ -185,5 +185,7 @@ __virBufferAdd; __virBufferAddChar; + __virMacAddrCompare; + local: *; }; Index: src/util.c === RCS file: /data/cvs/libvirt/src/util.c,v retrieving revision 1.22 diff -u -r1.22 util.c --- src/util.c 26 Feb 2008 07:05:18 - 1.22 +++ src/util.c 26 Feb 2008 13:10:46 - @@ -602,6 +602,16 @@ return 0; } +/* Use this function when comparing two MAC addresses. It deals with + * string case compare and will eventually be extended to understand + * that 01:02:03:04:05:06 is the same as 1:2:3:4:5:6. + */ +int +__virMacAddrCompare (const char *mac1, const char *mac2) +{ +return strcasecmp (mac1, mac2); +} + /* * Local variables: * indent-tabs-mode: nil Index: src/util.h === RCS file: /data/cvs/libvirt/src/util.h,v retrieving revision 1.11 diff -u -r1.11 util.h --- src/util.h 26 Feb 2008 07:05:18 - 1.11 +++ src/util.h 26 Feb 2008 13:10:46 - @@ -79,4 +79,7 @@ unsigned long long *result); #define virStrToLong_ull(s,e,b,r) __virStrToLong_ull((s),(e),(b),(r)) +int __virMacAddrCompare (const char *mac1, const char *mac2); +#define virMacAddrCompare(mac1,mac2) __virMacAddrCompare((mac1),(mac2)) + #endif /* __VIR_UTIL_H__ */ Index: src/virsh.c === RCS file: /data/cvs/libvirt/src/virsh.c,v retrieving revision 1.133 diff -u -r1.133 virsh.c --- src/virsh.c 22 Feb 2008 15:55:04 - 1.133 +++ src/virsh.c 26 Feb 2008 13:10:50 - @@ -4742,7 +4742,7 @@ while (cur != NULL) { if (cur-type == XML_ELEMENT_NODE xmlStrEqual(cur-name, BAD_CAST mac)) { tmp_mac = xmlGetProp(cur, BAD_CAST address); -diff_mac = xmlStrcasecmp(tmp_mac, BAD_CAST mac); +diff_mac = virMacAddrCompare ((char *) tmp_mac, mac); xmlFree(tmp_mac); if (!diff_mac) { goto hit; Index: src/xm_internal.c === RCS file: /data/cvs/libvirt/src/xm_internal.c,v retrieving revision 1.64 diff -u -r1.64 xm_internal.c --- src/xm_internal.c 20 Feb 2008 15:29:13 - 1.64 +++ src/xm_internal.c 26 Feb 2008 13:10:52 - @@ -53,6 +53,7 @@ #include xml.h #include buf.h #include uuid.h +#include util.h static int xenXMConfigSetString(virConfPtr conf, const char *setting, const char *str); @@ -2812,7 +2813,7 @@ key = nextkey; } -if (!(strcmp(dommac, (const char *) mac))) { +if (virMacAddrCompare (dommac, (const char *) mac) == 0) { if (autoassign) { free(mac); mac = NULL; @@ -3087,7 +3088,7 @@ mac = nextmac; } -if
Re: [Libvir] [PATCH]Change MAC address to case insensitive
OK, try this patch. I tried this patch. It works fine to me. Shigeki Sakamoto. -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list