[libvirt] [PATCH v2] vz: fixed race in vzDomainAttach/DettachDevice

While dettaching/attaching device in OpenStack, nova calls vzDomainDettachDevice twice, because the update of the internal configuration of the ct comes a bit latter than the update event. As the result, we suffer from the second call to dettach the same device. Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com> --- src/vz/vz_driver.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 2ed12db..26b14a2 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -1193,6 +1193,9 @@ static int vzDomainAttachDeviceFlags(virDomainPtr domain, const char *xml, if (prlsdkAttachDevice(driver, dom, dev) < 0) goto cleanup; + if (prlsdkUpdateDomain(driver, dom) < 0) + goto cleanup; + ret = 0; cleanup: virDomainDeviceDefFree(dev); @@ -1245,6 +1248,9 @@ static int vzDomainDetachDeviceFlags(virDomainPtr domain, const char *xml, if (prlsdkDetachDevice(driver, dom, dev) < 0) goto cleanup; + if (prlsdkUpdateDomain(driver, dom) < 0) + goto cleanup; + ret = 0; cleanup: virDomainDeviceDefFree(dev); -- 1.8.3.1

Ack On 18.08.2016 15:37, Olga Krishtal wrote:
While dettaching/attaching device in OpenStack, nova calls vzDomainDettachDevice twice, because the update of the internal configuration of the ct comes a bit latter than the update event. As the result, we suffer from the second call to dettach the same device.
Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com> --- src/vz/vz_driver.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 2ed12db..26b14a2 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -1193,6 +1193,9 @@ static int vzDomainAttachDeviceFlags(virDomainPtr domain, const char *xml, if (prlsdkAttachDevice(driver, dom, dev) < 0) goto cleanup;
+ if (prlsdkUpdateDomain(driver, dom) < 0) + goto cleanup; + ret = 0; cleanup: virDomainDeviceDefFree(dev); @@ -1245,6 +1248,9 @@ static int vzDomainDetachDeviceFlags(virDomainPtr domain, const char *xml, if (prlsdkDetachDevice(driver, dom, dev) < 0) goto cleanup;
+ if (prlsdkUpdateDomain(driver, dom) < 0) + goto cleanup; + ret = 0; cleanup: virDomainDeviceDefFree(dev);

18-Aug-16 17:04, Mikhail Feoktistov пишет:
Ack
On 18.08.2016 15:37, Olga Krishtal wrote:
While dettaching/attaching device in OpenStack, nova calls vzDomainDettachDevice twice, because the update of the internal configuration of the ct comes a bit latter than the update event. As the result, we suffer from the second call to dettach the same device.
Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com> --- src/vz/vz_driver.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 2ed12db..26b14a2 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -1193,6 +1193,9 @@ static int vzDomainAttachDeviceFlags(virDomainPtr domain, const char *xml, if (prlsdkAttachDevice(driver, dom, dev) < 0) goto cleanup; + if (prlsdkUpdateDomain(driver, dom) < 0) + goto cleanup; + ret = 0; cleanup: virDomainDeviceDefFree(dev); @@ -1245,6 +1248,9 @@ static int vzDomainDetachDeviceFlags(virDomainPtr domain, const char *xml, if (prlsdkDetachDevice(driver, dom, dev) < 0) goto cleanup; + if (prlsdkUpdateDomain(driver, dom) < 0) + goto cleanup; + ret = 0; cleanup: virDomainDeviceDefFree(dev);
Pushed now. Thanks. Maxim
participants (3)
-
Maxim Nestratov
-
Mikhail Feoktistov
-
Olga Krishtal