Skip to content

Commit

Permalink
F #-: implement crash detection for qemu vms
Browse files Browse the repository at this point in the history
Signed-off-by: Philippe Kueck <[email protected]>
  • Loading branch information
philfry committed Sep 8, 2020
1 parent aa7b907 commit 6dc7388
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/cli/onevm
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@ CommandParser::CmdParser.new(ARGV) do
configuration attributes are:
OS = ["ARCH", "MACHINE", "KERNEL", "INITRD", "BOOTLOADER", "BOOT"]
FEATURES = ["ACPI", "PAE", "APIC", "LOCALTIME", "HYPERV", "GUEST_AGENT"]
FEATURES = ["ACPI", "PAE", "APIC", "LOCALTIME", "HYPERV", "GUEST_AGENT", "CRASH_ACTION"]
INPUT = ["TYPE", "BUS"]
GRAPHICS = ["TYPE", "LISTEN", "PASSWD", "KEYMAP" ]
RAW = ["DATA", "DATA_VMX", "TYPE"]
Expand Down
1 change: 1 addition & 0 deletions src/oca/go/src/goca/schemas/vm/keys/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const (
LocalTime Feature = "LOCAL_TIME"
GuestAgent Feature = "GUEST_AGENT"
VirtIOScsiQueues Feature = "VIRTIO_SCSI_QUEUES"
CrashAction FEATURE = "CRASH_ACTION"
)

// IOGraphics define keys for the VM IO graphics
Expand Down
2 changes: 1 addition & 1 deletion src/oca/ruby/opennebula/virtual_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ def delete(recreate=false)
# will replace the existing ones or delete it if empty. Attributes that
# can be updated are: INPUT/{TYPE, BUS}; RAW/{TYPE, DATA, DATA_VMX},
# OS/{BOOT, BOOTLOADER, ARCH, MACHINE, KERNEL, INITRD},
# FEATURES/{ACPI, APIC, PAE, LOCALTIME, HYPERV, GUEST_AGENT},
# FEATURES/{ACPI, APIC, PAE, LOCALTIME, HYPERV, GUEST_AGENT, CRASH_ACTION},
# and GRAPHICS/{TYPE, LISTEN, PASSWD, KEYMAP}
# @return [nil, OpenNebula::Error] nil in case of success, Error
# otherwise
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,20 @@
</select>
</label>
</div>
<div class="medium-6 columns">
<label>
{{tr "QEMU Crash Detection"}}
{{{tip (tr "Action on VM crash. Leave blank to skip installation of crash device.")}}}
<select wizard_field="CRASH_ACTION">
<option value=""></option>
<option value="destroy">{{tr "Destroy"}}</option>
<option value="restart">{{tr "Restart"}}</option>
<option value="preserve">{{tr "Preserve"}}</option>
<option value="coredump-destroy">{{tr "Coredump and Destroy"}}</option>
<option value="coredump-restart">{{tr "Coredump and Restart"}}</option>
</select>
</label>
</div>
</div>
</div>
<div class="wizard_internal_tab tabs-panel cpuTab" id="cpuTab{{uniqueId}}">
Expand Down
2 changes: 1 addition & 1 deletion src/vm/VirtualMachine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2743,7 +2743,7 @@ void VirtualMachine::get_public_clouds(const string& pname, set<string> &clouds)
static std::map<std::string,std::vector<std::string>> UPDATECONF_ATTRS = {
{"OS", {"ARCH", "MACHINE", "KERNEL", "INITRD", "BOOTLOADER", "BOOT", "KERNEL_CMD", "ROOT", "SD_DISK_BUS"} },
{"FEATURES", {"PAE", "ACPI", "APIC", "LOCALTIME", "HYPERV", "GUEST_AGENT",
"VIRTIO_SCSI_QUEUES"} },
"VIRTIO_SCSI_QUEUES", "CRASH_ACTION"} },
{"INPUT", {"TYPE", "BUS"} },
{"GRAPHICS", {"TYPE", "LISTEN", "PASSWD", "KEYMAP", "COMMAND"} },
{"RAW", {"TYPE", "DATA", "DATA_VMX"} },
Expand Down
11 changes: 11 additions & 0 deletions src/vmm/LibVirtDriverKVM.cc
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,8 @@ int LibVirtDriver::deployment_description_kvm(
int virtio_scsi_queues = 0;
int scsi_targets_num = 0;

string crash_action = "";

string hyperv_options = "";

vector<const VectorAttribute *> raw;
Expand Down Expand Up @@ -1604,6 +1606,7 @@ int LibVirtDriver::deployment_description_kvm(
get_attribute(vm, host, cluster, "FEATURES", "LOCALTIME", localtime);
get_attribute(vm, host, cluster, "FEATURES", "GUEST_AGENT", guest_agent);
get_attribute(vm, host, cluster, "FEATURES", "VIRTIO_SCSI_QUEUES", virtio_scsi_queues);
get_attribute(vm, host, cluster, "FEATURES", "CRASH_ACTION", crash_action);

if ( acpi || pae || apic || hyperv )
{
Expand Down Expand Up @@ -1651,6 +1654,14 @@ int LibVirtDriver::deployment_description_kvm(
<< "\t</devices>" << endl;
}

if ( !crash_action.empty() )
{
file << "\t<on_crash>" << crash_action << "</on_crash>" << endl
<< "\t<devices>" << endl
<< "\t\t<panic model='isa'/>" << endl
<< "\t</devices>" << endl;
}

if ( virtio_scsi_queues > 0 || scsi_targets_num > 1)
{
file << "\t<devices>" << endl
Expand Down
2 changes: 1 addition & 1 deletion src/vmm_mad/exec/vmm_exec_kvm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

OS = [ arch = "x86_64" ]
FEATURES = [ PAE = "no", ACPI = "yes", APIC = "no", HYPERV = "no", GUEST_AGENT = "no",
VIRTIO_SCSI_QUEUES = "0" ]
VIRTIO_SCSI_QUEUES = "0", CRASH_ACTION = "" ]
#CPU_MODEL = [ MODEL = "host-passthrough"]
DISK = [ driver = "raw" , cache = "none"]

Expand Down

0 comments on commit 6dc7388

Please sign in to comment.