Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix recreating VM defined by devices issue:1331 #1348

Closed
wants to merge 2 commits into from
Closed

Fix recreating VM defined by devices issue:1331 #1348

wants to merge 2 commits into from

Conversation

jzupka
Copy link
Contributor

@jzupka jzupka commented Jan 14, 2014

virt: qcontainer adds possibility to find device by params.
qemu: Fix recreating VM defined by devices

It should solve problems in issue
#1331

@ldoktor
Copy link
Member

ldoktor commented Jan 15, 2014

Hi Jiří, I like the idea. Please take a look at my questions...

@ldoktor
Copy link
Member

ldoktor commented Jan 15, 2014

@jzupka there is one big problem with this. In case the fds or whatever changes, make_create_command returns different output and VM will be recreated with fresh params. So all the effort would be wasted. Instead of all this handling we could simply detect the different fds/ports and delete devices instead. Different scripts should be detected automatically as params differs.

On the other hand if we really want to keep the VM we could update these params in later part of preprocess.

@ldoktor
Copy link
Member

ldoktor commented Jan 15, 2014

Actually I followed the env_preprocess and the simplest solution and actually even bugfix (probably fixes the issue #1331 too) is to remove self.devices here:

diff --git a/virttest/virt_vm.py b/virttest/virt_vm.py
index 689b807..1985ae8 100644
--- a/virttest/virt_vm.py
+++ b/virttest/virt_vm.py
@@ -587,6 +587,7 @@ class BaseVM(object):
                 logging.debug("\t" + str(self.virtnet))
                 logging.debug("\t!=")
                 logging.debug("\t" + str(other_virtnet))
+                self.devices = None
                 return True
             else:
                 logging.debug(

@ldoktor
Copy link
Member

ldoktor commented Jan 15, 2014

Well and the safest way around this would be to skip optimization and recreate devices always in case vm is recreated by env:

diff --git a/virttest/env_process.py b/virttest/env_process.py
index e129110..0bcb2c6 100644
--- a/virttest/env_process.py
+++ b/virttest/env_process.py
@@ -113,6 +113,7 @@ def preprocess_vm(test, params, env, name):
                 if vm.needs_restart(name=name,
                                     params=params,
                                     basedir=test.bindir):
+                    self.devices = None
                     start_vm = True
                     old_vm.destroy(gracefully=gracefully_kill,
                                    free_mac_addresses=False)

@jzupka
Copy link
Contributor Author

jzupka commented Jan 15, 2014

New version of patch for commnets in commit https://github.com/jzupka/virt-test/commit/db9fe97f7fea61b184df2470c99c8b5e4f65c729

Unfortunately the changes that you suggest are not applicable because self.devices needs to be use in some cases. Hence some changes were done weeks ago. It allows moving and making special changes in special cases. For example during migration when I need to delete some device from VM before migration. This changes allows move vm without ugly hacking in env_preproces or what ever. Something like persistent and executable vm instance movable over network without changes.

@jzupka
Copy link
Contributor Author

jzupka commented Jan 15, 2014

After talking with @ldoktor added vm.device=None. For avoid errors between tests. Thanks for ideas.

@jzupka
Copy link
Contributor Author

jzupka commented Jan 16, 2014

@ldoktor yes there is another bug. I'll fix it and I send another patch

@jzupka
Copy link
Contributor Author

jzupka commented Jan 20, 2014

@ldoktor @lmr please take a look on that.

@jzupka
Copy link
Contributor Author

jzupka commented Jan 20, 2014

for testing:

sudo AUTOTEST_PATH=../../../ ./run -v -t qemu  --no-downloads  -g Fedora.19.x86_64 --verbose -m 512 --qemu_sandbox=off --no-cleanup --tests="boot shutdown" -k --keep-image-between-tests --nettype=user --machine-type=q35 --keep-guest-running 

@jzupka
Copy link
Contributor Author

jzupka commented Jan 22, 2014

@ldoktor
Copy link
Member

ldoktor commented Jan 23, 2014

Hi Jiří, another maybe stupid question, do we really need the info about those dynamic parameters? I mean is there a benefit of having them stored and not always generated during vm.create() function accordingly to the current params? It would be perfectly clean and simple and currently I'm not able to think of the possible drawback (comparison could be tricky, but solvable with the special device). The number of required modification would be minimal.

@jzupka
Copy link
Contributor Author

jzupka commented Jan 23, 2014

Hi Lukáš, thank you for your reaction. I think there is also another solution. If I have special device for everything what is someway strange and when you suggest wiring there "ok mac addr and fds and what ever will not be compared any more". Then there could be another way how to do this. _Simply don't compare dynamic things at all._ I wanted to avoid this solution because I afraid of removing full compare function. However, if you suggest create special object for every dev then we can remove full compare function and let there only compare without dynamic parameters. With using this solution it will be clean.

What you think about this solution?

We both want find someway how to fix this problem. I prefer general solution. I don't like wiring of something if I don't really afraid of speed and it is really not necessary do this. If you really want do wired solution with replacement of vritnet then somebody else do this. I don't want spend mi time on this in this case.

@ldoktor
Copy link
Member

ldoktor commented Jan 27, 2014

Hi Jiří, it seems to work fine. It even fixes the unnecessarily recreation on MAC addr change (two ./run executions) without any issues from using the old MAC address (tested with forced dhcp addr change). Thanks.

I believe this is ready for inclusion, even thought I'd prefer to remove all _nd functions and modify the original commands to support additional parameter, which would differentiate between normal and no_dynamic output. They booth do the same thing so it should be the same command. Usually booth commands are very similar, only in no_dynamic you replace some params with "DYN" keyword. Anyway this is only my opinion and I know you have different one. So let's the second reviewer (@lmr, @ypu or @zhouqt) decide, which one gets most votes ;-)

Acked-by: Lukáš Doktor [email protected]

@lmr
Copy link
Member

lmr commented Feb 4, 2014

@jzupka and @ldoktor I like the idea as well. Please, let's put this on shape for inclusion soon-ish. Thanks!

@jzupka
Copy link
Contributor Author

jzupka commented Feb 17, 2014

@lmr It worked for ldoktor. Please could you take a look on that too.

@ldoktor
Copy link
Member

ldoktor commented Feb 18, 2014

@jzupka I guess @lmr meant that you need to rebase this pull request so it can be included, right?

Allows to search specific device in qemu container by filter for
params. Created due to searching in the QStringDevices.

Signed-off-by: Jiří Župka <[email protected]>
@jzupka
Copy link
Contributor Author

jzupka commented Feb 18, 2014

@ldoktor you are probably right. @lmr rebased version :)

@ldoktor
Copy link
Member

ldoktor commented Feb 20, 2014

OK I tested this patch and still works as expected.

Acked-by: Lukáš Doktor [email protected]

@ldoktor
Copy link
Member

ldoktor commented Feb 20, 2014

^^ note there was one line which needed re-indentation, @jzupka, I hope you fixed it already...

This patch make qdevice more verbose during qcontainer comparison.
Also this patch add support for dynamic params in general devices
like QStringDevice and QCustomDevice and for devices classed inherited from them.

It sets cmdline with and without dynamic params for QStringDevice.
dev = QStringDevice(dev_type="xxx", cmdline="xxx:dynamicparam",
                                    cmdline_nd="xxx:DYN")

It allows specification which param is dynamic for QCustomDevice
dev = QCustomDevice(dev_type="xxx")
dev.set_param(name, value, something, dynamic True/False) default is true.

Comparison of qcontainer using == works as usual it compare all params
without dynamic params.

Some of qemu devices needs some kind of preparation before
start of qemu vm. Unfortunately there preparatory work are
done during creation of devices. For example network tap devices,
port redir, etc.
  It should be divided in some later patch.

Signed-off-by: Jiří Župka <[email protected]>
@jzupka
Copy link
Contributor Author

jzupka commented Feb 21, 2014

@ldoktor Indentation fixed. Thanks for review :-)

@lmr
Copy link
Member

lmr commented Feb 21, 2014

@jzupka, @ldoktor, I've rebased this and started testing... I've got a python core dump running the default qemu set, first test:

$ ./run -t qemu
Running setup. Please wait...
SETUP: PASS (15.62 s)
DATA DIR: /home/lmr/virt_test
DEBUG LOG: /home/lmr/Code/virt-test.git/logs/run-2014-02-21-15.09.49/debug.log
TESTS: 10
(1/10) type_specific.io-github-autotest-qemu.migrate.default.tcp:*** stack smashing detected ***: /usr/bin/python terminated
======= Backtrace: =========
/lib64/libc.so.6[0x3560a75cff]
/lib64/libc.so.6(__fortify_fail+0x37)[0x3560b06b17]
/lib64/libc.so.6(__fortify_fail+0x0)[0x3560b06ae0]
/usr/lib64/gstreamer-0.10/libgstvp8.so(+0x6587)[0x7f6c54fd2587]
/lib64/libgstbasevideo-0.10.so.23(+0xd12e)[0x7f6c54dc512e]
/lib64/libgstreamer-0.10.so.0(gst_pad_set_caps+0x197)[0x35632570f7]
/lib64/libgstreamer-0.10.so.0[0x3563258a92]
/lib64/libgstreamer-0.10.so.0(gst_pad_push+0x1a9)[0x356325c3b9]
/usr/lib64/gstreamer-0.10/libgstjpeg.so(+0x8e5f)[0x7f6c551dfe5f]
/lib64/libgstreamer-0.10.so.0[0x35632589c3]
/lib64/libgstreamer-0.10.so.0(gst_pad_push+0x1a9)[0x356325c3b9]
/lib64/libgstbase-0.10.so.0(+0x3564a27f3b)[0x7f6c671f4f3b]
/lib64/libgstreamer-0.10.so.0[0x3563282394]
/lib64/libglib-2.0.so.0[0x356366f406]
/lib64/libglib-2.0.so.0[0x356366ea45]
/lib64/libpthread.so.0[0x3561207f33]
/lib64/libc.so.6(clone+0x6d)[0x3560af4ded]

@lmr
Copy link
Member

lmr commented Feb 21, 2014

This by itself makes me not able to merge this. Did anyone of you @jzupka and @ldoktor seen this?

@ldoktor
Copy link
Member

ldoktor commented Feb 24, 2014

Well I haven't encounter this problem. Today I tested more tests and still without any problems running the same set of tests as you have...

btw @jzupka, it needs rebase again :-(

@lmr
Copy link
Member

lmr commented Feb 24, 2014

I did make a rebase, I can push the branch with the rebase. Unfortunately, the 'stack smashing' bug is one of the scariest I've seen in recent times, so we need to figure out where it comes from, and if it's some bug in the python version my machine (Fedora 20) runs.

@lmr lmr mentioned this pull request Feb 24, 2014
@lmr
Copy link
Member

lmr commented Feb 24, 2014

There you go, PR #1470, you could take a look at that @ldoktor and @jzupka

@lmr
Copy link
Member

lmr commented Feb 25, 2014

Ok, I found out that this was due to

https://bugzilla.redhat.com/show_bug.cgi?id=1068664

And not @jzupka's code. Phew :)

The code looks good to me, I'm going to push #1470

lmr added a commit that referenced this pull request Feb 25, 2014
@lmr lmr closed this Feb 25, 2014
@ldoktor
Copy link
Member

ldoktor commented Feb 25, 2014

Well I found one possible issue in qcontainer, @jzupka please take look on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants