Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

vc/qemu: add mutex to qmp monitor channel in qmpSetup() #2140

Merged
merged 1 commit into from
Nov 8, 2019

Conversation

YvesChan
Copy link
Contributor

Solve possible race condition in qmpSetup()

Fixes: #2139

Signed-off-by: Yves Chan [email protected]

@devimc
Copy link

devimc commented Oct 17, 2019

/test

thanks @YvesChan

@codecov
Copy link

codecov bot commented Oct 17, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@2082a9f). Click here to learn what that means.
The diff coverage is 100%.

@@            Coverage Diff            @@
##             master    #2140   +/-   ##
=========================================
  Coverage          ?   50.95%           
=========================================
  Files             ?      110           
  Lines             ?    15209           
  Branches          ?        0           
=========================================
  Hits              ?     7750           
  Misses            ?     6505           
  Partials          ?      954

Copy link
Contributor

@jodh-intel jodh-intel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @YvesChan!

Is there any way we can add a test (either a unit test here, or a test in https://github.com/kata-containers/tests) to give us some confidence the race has been fixed?

@YvesChan
Copy link
Contributor Author

Thanks @YvesChan!

Is there any way we can add a test (either a unit test here, or a test in https://github.com/kata-containers/tests) to give us some confidence the race has been fixed?

As I mentioned above, now the containerd-shim-kata-v2 process will hold the qmp.socket all the time, so there's no chance to reproduce the race condition in current runtime version. But it's not very convenient for user to debug the qemu issue if they cannot access qmp.socket since it's held by shim. So it's just better to make qmpSetup() more robust. What if we change the qmp connection to ephemeral(free after used) in the future? who knows :)

@GabyCT
Copy link
Contributor

GabyCT commented Oct 18, 2019

/test

@@ -921,6 +923,9 @@ func (q *qemu) togglePauseSandbox(pause bool) error {
}

func (q *qemu) qmpSetup() error {
q.qmpMonitorCh.Lock()
defer q.qmpMonitorCh.Unlock()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we get parallel qmp setup, is it possible to get parallel qmp shutdown as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, so we have to add this to qmpShutdown too. I'll fix this later. Thanks :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping. The commit message says "Solve possible race condition in qmpSetup() and qmpShutdown()" but the shutdown part seems missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

odd... I have already pushed that commit. Anyway, I do it again. Thanks :)

@YvesChan
Copy link
Contributor Author

/test

1 similar comment
@caoruidong
Copy link
Member

/test

Solve possible race condition in qmpSetup() and qmpShutdown()

Fixes: kata-containers#2139

Signed-off-by: Yves Chan <[email protected]>
@YvesChan
Copy link
Contributor Author

YvesChan commented Nov 6, 2019

/test

1 similar comment
@bergwolf
Copy link
Member

bergwolf commented Nov 6, 2019

/test

@jodh-intel
Copy link
Contributor

This is now ready to land but I'll let @bergwolf click the lovely green button as an ack to the comment about shutdown.

@jcvenegas jcvenegas merged commit d0615f8 into kata-containers:master Nov 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Race condition in qmpSetup
8 participants