KVM guest os boot error - linux

I'm trying to boot up a guest os to continue with my work but I have a problem with my virsh installation.
Here is the part of installation script:
qemu-img create -f qcow2 -o preallocation=metadata ~/images/${vm_name}.qcow2 ${pool_size}G
# create dir for images
mkdir ~/images/
virt-install \
--connect qemu:///system \
--name $vm_name \
--ram 10240 \
--vcpus 4 \
--disk ~/images/${vm_name}.qcow2,size=$pool_size,bus=virtio,sparse=false,format=qcow2 \
--network network=default,model=virtio \
--location http://ua.archive.ubuntu.com/dists/trusty-updates/main/installer-amd64/ \
--initrd-inject=$current_dir/preseed.cfg \
--extra-args="file=file:/preseed.cfg vga=788 quiet console=tty0 utf8 console=ttyS0,115200" \
--os-type=linux \
--virt-type kvm \
--video=vga \
--noreboot \
--cpu host \
--hvm
virsh start $vm_name
echo "----------Login to console----------"
virsh console $vm_name
WHen Im trying to run this script as a file like ./script.sh it produces an error:
Formatting '/home/{username}/images/test.qcow2', fmt=qcow2 size=53687091200 encryption=off cluster_size=65536 preallocation='metadata' lazy_refcounts=off refcount_bits=16
mkdir: cannot create directory '/home/flash/images/': File exists
ERROR 'DebianDistro' object has no attribute '_prefix'
error: failed to get domain 'test'
error: Domain not found: no domain with matching name 'test'
----------Login to console----------
error: failed to get domain 'test'
error: Domain not found: no domain with matching name 'test'
I have tried already reinstalling kvm qemu packages using this guide - https://help.ubuntu.com/community/KVM/Installation
and everything completed successfully.
I am sure that script will work file as I was using it before on the other machine without any problems.
Another try:
Using that script below
virt-install --connect qemu:///system -n test -r 10240 \
--vcpus=4 \
--disk path=/data0/images/test.img,size=50,format=qcow2,bus=virtio,cache=none \
--cdrom /home/{username}/Downloads/kvm/ubuntu-14.iso \
--vnc \
--os-type=linux \
--accelerate \
--network network=default \
--hvm
Produces an error:
ERROR internal error: process exited while connecting to monitor: Could not access KVM kernel module: Permission denied
failed to initialize KVM: Permission denied
Also when I'm trying to list all os variants by virt-install --os-variant list it cannot recognize this command and trying to boot up a guest os instead of listing variants.
Can you please help me to find out what is the problem here?

To fix this error:
ERROR 'DebianDistro' object has no attribute '_prefix'
Edit the file /usr/share/virt-manager/virtinst/urlfetcher.py and change this in line 1034:
if self._prefix:
to this:
if self._url_prefix:
Ubuntu 14.04.

Related

Error running gatk HaplotypeCaller with allele specific annotations

I've got HaplotypeCaller working nicely in standard mode, like so:
# Run haplotypcaller
gatk --java-options "-Xmx4g" HaplotypeCaller \
--intervals "$INTERVALS" \
-R "$REF" \
-I "$OUT"/results/alignment/${SN}_sorted_marked_recalibrated.bam \
-O "$OUT"/results/variants/${SN}_g.vcf.gz \
-ERC GVCF
But when I try in allele-specific mode, I get the following error. All I've done is add the -G annotations at the end, as suggested here.
# Haplytype caller with allele-specific annotations
gatk --java-options "-Xmx4g" HaplotypeCaller \
--intervals "$INTERVALS" \
-R "$REF" \
-I "$OUT"/results/alignment/${SN}_sorted_marked_recalibrated.bam \
-O "$OUT"/results/variants/${SN}_g.vcf.gz \
-ERC GVCF \
-G Standard \
-G AS_Standard
Here's the error:
***********************************************************************
A USER ERROR has occurred: Unrecognized annotation group name: Standard
***********************************************************************
I think that those options should be:
-G StandardAnnotation
-G AS_StandardAnnotation
At least, when I changed them to that, it didn't throw an error message.
However, I haven't used GATK much, so I'm not sure that's correct. I posted on the relevant Broad page, so more info may show up there.

How do I mount an external disk in qemu-system-ppc?

I am trying to use an external disk instead of a .img file in qemu-system-ppc. I am using the following code:
cd "$(dirname "$0")"
./qemu-system-ppc -L pc-bios -boot d -M mac99 -m 512 \
-prom-env 'auto-boot?=true' -prom-env 'boot-args=-v' -prom-env 'vga-ndrv?=true' \
-drive file=MacOS9.2.2.iso,format=raw,media=cdrom \
-drive file=/dev/disk3s2,format=raw,if=virtio \
-netdev user,id=network01 -device sungem,netdev=network01 \
-device VGA,edid=on \
When I run this code I get the following output from the terminal:
hamishmoore#Hamishs-Mini ~ % /Applications/QEMU\ Mac\ OS\ 9.2.2/qemu.command ; exit;
qemu-system-ppc: -drive file=/dev/disk3s2,format=raw,if=virtio: If device /dev/disk3s2 is mounted on the desktop, unmount it first before using it in QEMU
qemu-system-ppc: -drive file=/dev/disk3s2,format=raw,if=virtio: Command to unmount device: diskutil unmountDisk /dev/disk3s2
qemu-system-ppc: -drive file=/dev/disk3s2,format=raw,if=virtio: Command to mount device: diskutil mountDisk /dev/disk3s2
qemu-system-ppc: -drive file=/dev/disk3s2,format=raw,if=virtio: Could not open '/dev/disk3s2': Permission denied
[Process completed]
The disk has been unmounted from the desktop. And I've tried formatting the disk a few different ways. I am running macOS Catalina.
Help Appreciated.
QEMU will print the suggestion about unmounting from the desktop for pretty much any error attempting to open a device as an image file. The important line here is the last one, which tells you the specific error:
qemu-system-ppc: -drive file=/dev/disk3s2,format=raw,if=virtio: Could not open '/dev/disk3s2': Permission denied
"Permission denied" usually means that the user you're running QEMU as does not have write access to the /dev/disk3s2 device; check the permissions/ownership on it.

Gunicorn around 100% CPU usage

Sometimes my web server just stops responding.
What I found out is that at these moments Gunicorn processes' CPU load is around 100%. I have not changed codebase in a while so I don't think it might cause that.
Here's the bash script I use to run gunicorn:
#!/bin/bash
source /etc/profile.d/myapp.sh
NAME="myapp-web-services"
DJANGODIR="/home/myapp/myapp-web-services"
SOCKFILE=/tmp/myapp-web-services.sock
USER=myapp
GROUP=myapp
NUM_WORKERS=9
TIMEOUT=100
DJANGO_WSGI_MODULE=settings.wsgi
echo "Starting $NAME as `whoami`"
cd $DJANGODIR
source /home/myapp/.virtualenvs/myapp-web-services/bin/activate
export PYTHONPATH=$DJANGODIR:$PYTHONPATH
RUNDIR=$(dirname $SOCKFILE)
test -d $RUNDIR || mkdir -p $RUNDIR
exec newrelic-admin run-program /home/myapp/.virtualenvs/myapp-web-services/bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
--name $NAME \
--workers $NUM_WORKERS \
--user=$USER --group=$GROUP \
--bind=unix:$SOCKFILE \
--log-level=warning \
--timeout=$TIMEOUT \
--log-file=- \
--max-requests=1200
I have 4 CPUs in the system so according to documentation 9 workers should be fine.

Using ks.cfg with virt-install?

I've been trying to get a virtual machine working with a cfg file on centos but unfortunately, I'm getting the error that ks.cfg file does not exist.
Below is the command I ran to enable the VM.
virt-install --name FedoraTest --ram 1024 --disk pool=default,size=10 --location ~/Desktop/CentosOS --initrd-inject ks.cfg --extra-args "ks=file:~/Desktop/ks.cfg"
I am new to the VM setup and am unsure if I'm doing it right.
Any advice on how to fix this will be greatly appreciated.
Also, what does initrd-inject do? And is it possible to save the above command into a file and run the file instead?
I suppose you have switched the meaning of 'initrd-inject' and 'extra-args' parameters. The initrd-inject should contain path to the ks file in your file system, while in 'extra-args' you should specify kernel to use the injected ks file. See the snippet:
virt-install --connect=qemu:///system \
--network=bridge:br0 \
--initrd-inject=/export/rhel.ks \
--extra-args="ks=file:/rhel.ks console=tty0 console=ttyS0,115200" \
--name=$domname \
--disk /export/vmimgs/$domname.img,size=20 \
--ram 2048 \
--vcpus=2 \
--check-cpu \
--accelerate \
--hvm \
--location=$location1 \
--nographics
The snippet comes from here

virtualbox + perl + shared folder == fail

This is a convoluted one so bear with me. I have a Perl script that is located on a Windows VirtualBox guest. I want to call this script from the Linux host and have it read a shared folder from the host. The reading of the folder fails.
On the host I call this script and it gives me the following output:
host:~/$ ./script.pl /nfs/nasi/temp
[2014-04-02 10:50:55] Uploading file records to localhost
[2014-04-02 10:50:55] Running VirtualBox for Kaspersky
fatal: opendir(E:\nasi\temp) failed: No such file or directory
[2014-04-02 10:50:56] Uploading malware samples data to localhost
host:$
The script converts the argument /nfs/nasi/temp to E:\nasi\temp and calls the script using the following command:
/usr/bin/VBoxManage guestcontrol <guest> execute \
--image "C:\strawberry\perl\bin \perl.exe" \
--username <user> --password <pass> \
--wait-stdout --wait-stderr --wait-exit -- \
"C:\antivirus\kaspersky.pl" "E:\nasi\temp"
When I run this same script using the same option from the guest directly however I get the following:
C:\antivirus>C:\strawberry\perl\bin\perl.exe C:\antivirus\kaspersky.pl E:\nasi\temp
[2014-04-02 10:54:19] Running Kaspersky Antivirus
[2014-04-02 10:54:20] Parsing Kaspersky report
[2014-04-02 10:54:20] Uploading Kaspersky results to 10.0.0.1
C:\antivirus>
But wait, it gets weirder. When instead of providing the shared directory E:\ I instead point it to C:\ it has no problem reading the directory and just happily keeps going. So the error only shows up when I run the command from the host through VirtualBox and point it to the share.
Here is the relevant code:
sub createSamplesMap {
opendir( my $dh, $ARGV[0] ) or
die "fatal: opendir($ARGV[0]) failed: $!\n";
my #files = readdir( $dh );
foreach my $file ( #files ) {
if (! -d $file ) {
...
}
}
closedir($dh);
}
I tried different ways of reading the filenames from the directory but they didn't work. Here's what I tried.
my #files = <$ARGV[0]\\*>;
my #files = glob( $ARGV[0] . '\\*' );
I don't know whether to blame perl or virtualbox. Anyone have any ideas on what the problem might be?
Windows 7, Strawberry Perl v5.18.2
Ubuntu 12.04.04, Perl v5.14.2
VirtualBox 4.2.16r86992
crosspost: https://forums.virtualbox.org/viewtopic.php?f=2&t=61011
I've found the problem. As mentioned on the virtualbox forum there was a problem with the environment variables set when running the perl script. After much googling I also found a blog post from kissmyarch where he describes how he solved the problem.
You can set environment variables using the --environment option in VBoxManage guestcontrol and according to kissmyarch you need to set USERPROFILE to get it to work. This did not work for me.
So instead I used the following code from the script to figure out what environment variables were set:
foreach $key (sort keys(%ENV)) {
print "$key = $ENV{$key}\n";
}
and ran that both on the guest and from guestcontrol to compare the environments. My command now looks like this:
/usr/bin/VBoxManage guestcontrol <vm> execute \
--image "C:\strawberry\perl\bin\perl.exe" \
--username <user> --password <pass> \
--environment "USERPROFILE=C:\Users\<user>" \
--environment "APPDATA=C:\Users\<user>\AppData\Roaming" \
--environment "LOCALAPPDATA=C:\Users\<user>\AppData\Local" \
--environment "HOMEDRIVE=C:" \
--environment "HOMEPATH=\Users\<user>" \
--environment "LOGONSERVER=\\\<server>" \
--environment "SESSIONNAME=Console" \
--environment "TEMP=C:\Users\<user>\AppData\Local\Temp" \
--environment "TMP=C:\Users\<user>\AppData\Local\Temp" \
--environment "USERDOMAIN=<domain>" \
--environment "USERNAME=<user>" \
--wait-stdout --wait-stderr --wait-exit \
-- "C:\antivirus\kaspersky.pl" "E:\nasi\temp"
Somewhere in that big pile of environment variables is one that is important.
Thanks to all that helped.

Resources