Re: [libvirt] [PATCH]util:ovs:Delete port if it is exist when add port

2014-07-03 Thread Lichunhe
Resubmit the patch, remove '--may-exist' and I have tested, it work.

diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
index 9bcbfb1..2c414ad 100644
--- a/src/util/virnetdevopenvswitch.c
+++ b/src/util/virnetdevopenvswitch.c
@@ -84,8 +84,8 @@ int virNetDevOpenvswitchAddPort(const char *brname, const 
char *ifname,
 
 cmd = virCommandNew(OVSVSCTL);
 
-virCommandAddArgList(cmd, "--timeout=5", "--", "--may-exist", "add-port",
-brname, ifname, NULL);
+virCommandAddArgList(cmd, "--timeout=5", "--", "--if-exists", "del-port", 
+ifname, "--", "add-port", brname, ifname, NULL);
 
 if (virtVlan && virtVlan->nTags > 0) {


>-Original Message-
>From: libvir-list-boun...@redhat.com [mailto:libvir-list-boun...@redhat.com]
>On Behalf Of Lichunhe
>Sent: Thursday, July 03, 2014 9:21 PM
>To: Michal Privoznik; libvir-list@redhat.com
>Subject: Re: [libvirt] [PATCH]util:ovs:Delete port if it is exist when add port
>
>Yeah, the '--may-exist' could be removed, it is not useful.
>
>>-Original Message-----
>>From: Michal Privoznik [mailto:mpriv...@redhat.com]
>>Sent: Thursday, July 03, 2014 8:39 PM
>>To: Lichunhe; libvir-list@redhat.com
>>Subject: Re: [libvirt] [PATCH]util:ovs:Delete port if it is exist when
>>add port
>>
>>On 03.07.2014 13:57, Lichunhe wrote:
>>> If the ovs service stop abnormal, or host cold reboot, vm is
>>> destroyed after ovs service stop. The ovs port which connect to
>>> interface of vm will not be clear. When the ovs service restart,
>>> recover configuration from db, but the interface is no exist, port
>>> recovery failed, and then vm restart on the same host, libvirt add
>>> port again, but the port configuration is same as before, ovs will
>>> not connect the interface, only store the configuration in db. Below
>>> will trigger this problem,
>>>
>>> virsh start vm
>>> service openvswitch-switch stop
>>> virsh destroy vm
>>> service openvswitch-switch start
>>> virsh start vm
>>>
>>>
>>> Signed-off-by: Chunhe Li 
>>> ---
>>>
>>> src/util/virnetdevopenvswitch.c | 3 ++-
>>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/src/util/virnetdevopenvswitch.c
>>> b/src/util/virnetdevopenvswitch.c index 9bcbfb1..dd601c0 100644
>>> --- a/src/util/virnetdevopenvswitch.c
>>> +++ b/src/util/virnetdevopenvswitch.c
>>> @@ -84,7 +84,8 @@ int virNetDevOpenvswitchAddPort(const char
>*brname,
>>> const char *ifname,
>>>
>>>   cmd = virCommandNew(OVSVSCTL);
>>>
>>> -virCommandAddArgList(cmd, "--timeout=5", "--", "--may-exist",
>>"add-port",
>>> +virCommandAddArgList(cmd, "--timeout=5", "--", "--if-exists",
>>"del-port",
>>> +ifname, "--", "--may-exist", "add-port",
>>>   brname, ifname, NULL);
>>
>>So what's the meaning of '--may-exist' then? Does it do anything useful after
>all?
>>
>>Michal
>
>--
>libvir-list mailing list
>libvir-list@redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH]util:ovs:Delete port if it is exist when add port

2014-07-03 Thread Lichunhe
Yeah, the '--may-exist' could be removed, it is not useful.

>-Original Message-
>From: Michal Privoznik [mailto:mpriv...@redhat.com]
>Sent: Thursday, July 03, 2014 8:39 PM
>To: Lichunhe; libvir-list@redhat.com
>Subject: Re: [libvirt] [PATCH]util:ovs:Delete port if it is exist when add port
>
>On 03.07.2014 13:57, Lichunhe wrote:
>> If the ovs service stop abnormal, or host cold reboot, vm is destroyed
>> after ovs service stop. The ovs port which connect to interface of vm
>> will not be clear. When the ovs service restart, recover configuration
>> from db, but the interface is no exist, port recovery failed, and then
>> vm restart on the same host, libvirt add port again, but the port
>> configuration is same as before, ovs will not connect the interface,
>> only store the configuration in db. Below will trigger this problem,
>>
>> virsh start vm
>> service openvswitch-switch stop
>> virsh destroy vm
>> service openvswitch-switch start
>> virsh start vm
>>
>>
>> Signed-off-by: Chunhe Li 
>> ---
>>
>> src/util/virnetdevopenvswitch.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/util/virnetdevopenvswitch.c
>> b/src/util/virnetdevopenvswitch.c index 9bcbfb1..dd601c0 100644
>> --- a/src/util/virnetdevopenvswitch.c
>> +++ b/src/util/virnetdevopenvswitch.c
>> @@ -84,7 +84,8 @@ int virNetDevOpenvswitchAddPort(const char *brname,
>> const char *ifname,
>>
>>   cmd = virCommandNew(OVSVSCTL);
>>
>> -virCommandAddArgList(cmd, "--timeout=5", "--", "--may-exist",
>"add-port",
>> +virCommandAddArgList(cmd, "--timeout=5", "--", "--if-exists",
>"del-port",
>> +ifname, "--", "--may-exist", "add-port",
>>   brname, ifname, NULL);
>
>So what's the meaning of '--may-exist' then? Does it do anything useful after 
>all?
>
>Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH]util:ovs:Delete port if it is exist when add port

2014-07-03 Thread Michal Privoznik

On 03.07.2014 13:57, Lichunhe wrote:

If the ovs service stop abnormal, or host cold reboot, vm is destroyed after 
ovs service stop. The ovs
port which connect to interface of vm will not be clear. When the ovs service 
restart, recover configuration
from db, but the interface is no exist, port recovery failed, and then vm 
restart on the same host,
libvirt add port again, but the port configuration is same as before, ovs will 
not connect the interface,
only store the configuration in db. Below will trigger this problem,

virsh start vm
service openvswitch-switch stop
virsh destroy vm
service openvswitch-switch start
virsh start vm


Signed-off-by: Chunhe Li 
---

src/util/virnetdevopenvswitch.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
index 9bcbfb1..dd601c0 100644
--- a/src/util/virnetdevopenvswitch.c
+++ b/src/util/virnetdevopenvswitch.c
@@ -84,7 +84,8 @@ int virNetDevOpenvswitchAddPort(const char *brname, const 
char *ifname,

  cmd = virCommandNew(OVSVSCTL);

-virCommandAddArgList(cmd, "--timeout=5", "--", "--may-exist", "add-port",
+virCommandAddArgList(cmd, "--timeout=5", "--", "--if-exists", "del-port",
+ifname, "--", "--may-exist", "add-port",
  brname, ifname, NULL);


So what's the meaning of '--may-exist' then? Does it do anything useful 
after all?


Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH]util:ovs:Delete port if it is exist when add port

2014-07-03 Thread Lichunhe
If the ovs service stop abnormal, or host cold reboot, vm is destroyed after 
ovs service stop. The ovs
port which connect to interface of vm will not be clear. When the ovs service 
restart, recover configuration
from db, but the interface is no exist, port recovery failed, and then vm 
restart on the same host,
libvirt add port again, but the port configuration is same as before, ovs will 
not connect the interface,
only store the configuration in db. Below will trigger this problem,

virsh start vm
service openvswitch-switch stop
virsh destroy vm
service openvswitch-switch start
virsh start vm


Signed-off-by: Chunhe Li 
---

src/util/virnetdevopenvswitch.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
index 9bcbfb1..dd601c0 100644
--- a/src/util/virnetdevopenvswitch.c
+++ b/src/util/virnetdevopenvswitch.c
@@ -84,7 +84,8 @@ int virNetDevOpenvswitchAddPort(const char *brname, const 
char *ifname,
 
 cmd = virCommandNew(OVSVSCTL);
 
-virCommandAddArgList(cmd, "--timeout=5", "--", "--may-exist", "add-port",
+virCommandAddArgList(cmd, "--timeout=5", "--", "--if-exists", "del-port", 
+ifname, "--", "--may-exist", "add-port",
 brname, ifname, NULL);
 
 if (virtVlan && virtVlan->nTags > 0) {

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list