Welcome Guest. Please Login or Register  


You are here: Index > Virtualizor - Virtual Server Control Panel > Suggestions > Topic : Pass QEMU command line arguments in plans/new virtual servers



Threaded Mode | Print  

 Pass QEMU command line arguments in plans/new virtual servers (6 Replies, Read 25807 times)
m9shyamalan
Group: Member
Post Group: Newbie
Posts: 19
Status:
Hi Guys,

I have recently run into a situation where for some of our VM's require us to pass QEMU command line arguments to get functionality from our Virtual Servers that aren't achievable from the Virtualizor interface. To do this we are using 'virsh edit', but the issue is that these changes:

a) Can't be applied until after the Virtual Server has already been created
b) Have to be done manually for each Virtual Server, with no API support
c) Are reverted if the Virtualizor Interface/API is ever used to edit the Virtual Server

Currently our edits are just the following:
Change the top line of the XML from

PHP Code

 <domain type='kvm' id='2'


to
PHP Code

 <domain type='kvm' id='2' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'


After </devices> in the xml, we are adding the following section:
PHP Code

 <qemu:commandline>
    <
command line arguements/>
  </
qemu:commandline



Would it be possible for plans and new virtual server pages to have a tickbox for QEMU Command Line Arguments, which would unhide a free text box to add these command line options to, or even a standard KVM template to which we could add these changes?

Alternatively, if someone can suggest an existing method to add QEMU command line arguments automatically to new Virtual Servers/Plans, I would love to hear it!

Thanks
IP: --   

Pass QEMU command line arguments in plans/new virtual servers
jevingala
Group: Virtualizor Team
Post Group: Super Member
Posts: 739
Status:
Hi,

You can try using hooks to write custom config in vps config file :

https://www.virtualizor.com/docs/developers/hooks/#after_config_write

-----------------------
Regards,
Virtualizor Team.
http://virtualizor.com/
IP: --   

Pass QEMU command line arguments in plans/new virtual servers
m9shyamalan
Group: Member
Post Group: Newbie
Posts: 19
Status:
Quote From : jevingala July 26, 2019, 3:03 pm
Hi,

You can try using hooks to write custom config in vps config file :

https://www.virtualizor.com/docs/developers/hooks/#after_config_write


Exactly what I was looking for! Thanks, I will give it a shot and report back.
IP: --   

Pass QEMU command line arguments in plans/new virtual servers
m9shyamalan
Group: Member
Post Group: Newbie
Posts: 19
Status:
Quote From : jevingala July 26, 2019, 3:03 pm
Hi,

You can try using hooks to write custom config in vps config file :

https://www.virtualizor.com/docs/developers/hooks/#after_config_write


Hi Jev,

Do you know if these hooks output logs anywhere? I Couldn't find any information in the documentation, and I'm trying to troubleshoot an error.

I am seeing  "There was an error in editing the VPS" when the after_config_write.php hook is in place. The VM is being edited as per the changes on the GUI, but the hook is not running.

I am able to manually run the function from the command line, which is running as expected, so I am hoping to find the output Virtualizor is seeing to track down the problem.

Thanks
IP: --   

Pass QEMU command line arguments in plans/new virtual servers
chirag
Group: Virtualizor Team
Post Group: Elite Member
Posts: 419
Status:
Hi,

Sir can you send us the hook file ?
So that we can check on our server ?

-----------------------
Virtualizor - VPS Control Panel
Follow us on Facebook
IP: --   

Pass QEMU command line arguments in plans/new virtual servers
m9shyamalan
Group: Member
Post Group: Newbie
Posts: 19
Status:
Hey Guys,

This issue is now resolved, just wanted to post back so if anyone else has this issue.

I read the document linked by jevingala:
https://www.virtualizor.com/docs/developers/hooks/#after_config_write

and built off the example function, but was getting an error message every time I edited a VM. My mistake was not correctly adding the PHP codes at the start and end of the document, and following the documentation blindly.

FYI my complete script looks like this:
PHP Code

<?php
function __after_config_write($vps){
$path '/etc/libvirt/qemu/'.$vps['vps_name'].'.xml';
$xml file_get_contents($path);
$schema str_replace("<domain type='kvm'>""<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>"$xml);
file_put_contents($path$schema);
$xml file_get_contents($path);
$cpu str_replace("</devices>""</devices>n    <qemu:commandline>n        insert your arguments heren    </qemu:commandline>"$xml);
file_put_contents($path$cpu);
}
?>



Hope this helps anyone else having issues
IP: --   

Pass QEMU command line arguments in plans/new virtual servers
chirag
Group: Virtualizor Team
Post Group: Elite Member
Posts: 419
Status:
Hi,

Sir glad to know that your issue is resolved.
Let us know for further information.
We will be happy to help you.

-----------------------
Virtualizor - VPS Control Panel
Follow us on Facebook
IP: --   

« Previous    Next »

Threaded Mode | Print  



Jump To :


Users viewing this topic
1 guests, 0 users.


All times are GMT. The time now is March 28, 2024, 9:26 pm.

  Powered By AEF 1.0.8 © 2007-2008 Electron Inc.Queries: 11  |  Page Created In:0.027