How to use already created img on qemu - vmware

I use VMware and then install qemu on it.
Create img.
$ sudo qemu-img create -f qcow2 mini3.img 5G
Then create a virtual machine.
$ sudo qemu-system-x86_64 -m 1024 -enable-kvm -hda mini3.img -cdrom ./minix_R3.3.0-588a35b.iso -boot d
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000001H:ECX.svm [bit 2]
And I turn off this virtual machine and then start the created virtual machine.
$ sudo qemu-system-x86_64 -m 2048 -enable-kvm -hda mini3.img
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000001H:ECX.svm [bit 2]
But no success.
Where is the problem?

I would guess that in the first run your OS is booting from cdrom image (minix_R3.3.0-588a35b.iso). In the second run you removed it, and there is only a hard drive image (mini3.img). You probably failed to properly install the OS in the first run to your hard drive image.

Related

Shell script stops when calling SSH

I am attempting to automate a few things on AWS with one script.
log in and shut down docker-compose then remove all images
copy local files to server
log in and start docker-compose
My script is
#log in and shut down docker-compose then remove all images
ssh -i "~/Documents/AWS-Keys/mykey.pem" ubuntu#XX.XXX.XX.XXX
docker-compose down
docker image prune -f
exit
#copy local files to server
scp -r -i "~/Documents/AWS-Keys/mykey.pem" ./ubuntu ubuntu#XX.XXX.XX.XXX:/home
#log in and start docker-compose
ssh -i "~/Documents/AWS-Keys/mykey.pem" ubuntu#XX.XXX.XX.XXX
docker-compose up -d
exit
I have also tried logout instead of exit, same result.
Running
$ ./upload.sh
The output is:
Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-1038-aws x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Tue Mar 2 21:52:40 UTC 2021
System load: 0.07
Usage of /: 66.0% of 7.69GB
Memory usage: 36%
Swap usage: 0%
Processes: 115
Users logged in: 1
IPv4 address for xxxxxxxxxxxxxxx: XXX.XX.X.X
IPv4 address for docker0: XXX.XX.X.X
IPv4 address for eth0: XXX.XX.X.XXX
* Introducing self-healing high availability clusters in MicroK8s.
Simple, hardened, Kubernetes for production, from RaspberryPi to DC.
https://microk8s.io/high-availability
3 updates can be installed immediately.
0 of these updates are security updates.
To see these additional updates run: apt list --upgradable
Last login: Tue Mar 2 21:51:47 2021 from XXX.XX.X.XXX
ubuntu#ip-XXX.XX.X.XXX:~$
After getting some feedback I also tried
ssh -i "~/Documents/AWS-Keys/mykey.pem" ubuntu#XX.XXX.XX.XXX
docker-compose down;
docker image prune -f;
exit
Same result.
My understanding is that you want to run the command on the server, in that case just write it after ssh:
ssh -i "~/Documents/AWS-Keys/mykey.pem" ubuntu#XX.XXX.XX.XXX "docker-compose down ;docker image prune -f"
a longer script you can send via HEREDOC
ssh -i "~/Documents/AWS-Keys/mykey.pem" ubuntu#XX.XXX.XX.XXX <<COMMANDS
docker-compose down
docker image prune -f
COMMANDS

problem with remote lldb debugger into docker container

Setup is a docker container running ubuntu 16.04, clang/lldb 6.0. I want to be able to remote debug an application, for now via another terminal instead of an IDE.
My docker file
FROM ubuntu:16.04
RUN apt update
RUN apt install -y curl git nano cmake build-essential xz-utils
RUN apt install -y clang-6.0 lldb-6.0
EXPOSE 2000
CMD [ "/bin/bash" ]
I spin my container as follows
docker run --privileged --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -it -v ~/Developer:/Developer -p 2000:2000 --name cpp-dev ubuntu-clang-dev
Debugging from within the container works
I can successfully compile and debug my program with clang++ and lldb when inside the container.
How I start my lldb-server
lldb-server-6.0 platform --server --listen *:2000
Now, from a separate terminal I do:
> lldb
> platform select remote-linux
> platform connect connect://localhost:2000
> target create test
> b main (which returns breakpoint main at main.cpp:5)
> process launch
Errors:
(lldb) process launch
error: connect remote failed (Failed to connect port)
error: process launch failed: Failed to connect port
What am I doing wrong?
I found it myself.
LLDB-server listens on port 2000 for incoming connections. Upon receiving such a request it spawns a separate 'lldb g : '. This secret port is not open to the outside world from my vm.
The easiest trick that works for me is to just have the container run on the same network as the host. Hence, once I start my container with:
docker run --privileged --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -it -v ~/Developer:/Developer **--network host** --name cpp-dev ubuntu-clang-dev
it all works fine and I can run the lldb from the host as advertised.
You can specify the ports used by LLDB-server as such:
lldb-server platform --listen "*:31166" --server --min-gdbserver-port 31200 --max-gdbserver-port 31300
And of course you need to expose those ports in your Dockerfile:
EXPOSE 31166
EXPOSE 31200-31300
And also when you run the container:
docker run --privileged --name vapor-server -p 8080:8080 -p 31166:31166 -p 31200-31300:31200-31300 vapor-image
Please note you need to run the docker as privileged (--privileged option), otherwise attaching the debugger will fail with an Operation not Permitted error.

Cannot open firefox browser via X11

When I try to start firefox on ec2 instance (centos/7) via X11, I got an error.
Is there a way to solve this?
I'm already confirmed that other GUI application, sucy as xeyes or eog, can be launched.
Env
ec2 side
OS: Centos 7.3.1611 (Core)
SELinux: Enforcing
xauth version: 1.0.9
xterm version: X.Org 7.6.0(295)
xorg-x11-apps.x86_64: 7.7-6.el7
$ sudo cat /etc/ssh/sshd_config
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
SyslogFacility AUTHPRIV
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no
ChallengeResponseAuthentication no
GSSAPIAuthentication yes
GSSAPICleanupCredentials no
UsePAM yes
X11Forwarding yes
X11UseLocalhost no
UsePrivilegeSeparation sandbox # Default for new installations.
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS
Subsystem sftp /usr/libexec/openssh/sftp-server
local side
OS: Mac OS X 10.11.6
XQuartz version: 2.7.11 (xorg-server 1.18.4)
$ sudo cat /etc/ssh/sshd_config
# Apple:
Host *
SendEnv LANG LC_*
Host *
XAuthLocation /opt/X11/bin/xauth
Reproduction scenario
# ec2 side
sudo yum -y install xauth xterm xorg-x11-apps xeyes
exit
# local side
ssh -X fhiyo#ec2-xx-xx-xx-xx.ap-northeast-1.compute.amazonaws.com
# ec2 side
xeyes # OK
sudo yum -y install eog
eog path/to/sample.png # OK
sudo yum -y install firefox
$ firefox
[Parent 20819] WARNING: pipe error (36): Connection reset by peer: file /builddir/build/BUILD/firefox-52.2.0/firefox-52.2.0esr/ipc/chromium/src/chrome/common/ipc_channel_posix.cc, line 322
###!!! [Parent][MessageChannel] Error: (msgtype=0x46000E,name=PContent::Msg_NotifyLayerAllocated) Channel error: cannot send/recv
...
[Parent 20819] WARNING: FileDescriptorSet destroyed with unconsumed descriptors: file /builddir/build/BUILD/firefox-52.2.0/firefox-52.2.0esr/ipc/chromium/src/chrome/common/file_descriptor_set_posix.cc, line 22
###!!! [Parent][MessageChannel] Error: (msgtype=0x2C0085,name=PBrowser::Msg_Destroy) Channel error: cannot send/recv
I had a similar problem when launching Firefox version 52.3.0 with X11 forwarding on CentOS 7 :
WARNING: pipe error (35): Connexion ré-initialisée par le correspondant: file /builddir/build/BUILD/firefox-52.3.0/firefox-52.3.0esr/ipc/chromium/src/chrome/common/ipc_channel_posix.cc, line 322
And same error (in french) on firefox "Gah, you tab just crash"
To correct this, i tried first to update all the package without success.
So i combined two solutions i found on the net :
1- I opened the "about:config" page (just type about:config in the url field then enter) and changed to "false" the 2 options browser.tabs.config.autostart and browser.tabs.config.autostart2
2- I opened the "about:support" page and click on "Repair Firefox..."
Then it works ! but i still have the following problem : i need to do this each time i relaunch firefox; So i should not close all tabs.
Check your SELinux configuration. In special check that mozilla_plugin_can_network_connect is enabled. You can do: getsebool mozilla_plugin_can_network_connect if answer is off then do setsebool -P mozilla_plugin_can_network_connect=1. Then try again firefox&

VDI usage inconsistent between host and guest

vbox 5.0.24, ubuntu 16.04 on host & guest (myguest) with dynamically allocated VDI.
Why was the VDI usage vastly inconsistent between host and guest, when I checked it below?
$ du -h myguest.vdi # from the host
5G
$ df -h --total # from the guest
... used
...
total ... 2G
#Solution
boot guest to recovery mode [Esc, Enter]
choose drop to root shell [Down, Enter]
go to Maintenance [Enter]
# mount -o remount,ro /dev/sda[id] /
# zerofree /dev/sda[id]
# shutdown -P now
shrink the guest VDI from the host via,
$ VBoxManage modifyhd [guest].vdi --compact
Reference:
https://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvdi
https://unix.stackexchange.com/questions/11100/how-to-make-ext4-filesystem-sparse
http://ubuntuforums.org/archive/index.php/t-908128.html

Running APE Server in a Virtual Machine

I have been trying to set-up an Ajax Push Engine (APE) Server in a virtual machine, and have run into a bit of a snag. The problem is that the APE server cannot be accessed outside of the virtual machine.
Setup:
Guest OS: Ubuntu 10.10 (I believe) with the ape package installed
IP Address: 192.168.56.1 using a host-only network adapter
APE Server running on port 6969
If I try wget 127.0.0.1:6969 in the virtual machine, I get a response.
If I try wget 192.168.56.1:6969 from the host OS, I get a Connection Refused message.
If I ping 192.168.56.1, I also get a response.
Any help would be greatly appreciated!
I ended up redoing everything from scratch, and it worked, so I must have got it right somehow. For the benefit of others...
To get APE Server running in a virtual machine (in particular, using VirtualBox), you need to do the following:
Setting up the environment
Download and install VirtualBox
Open VirtualBox, and go to File > Preferences, then Network
Confirm that there exists a host-only network vboxnet0 (if not, create it). Take note of its IPv4 address (192.168.56.1, in my case)
Create a new Ubuntu Virtual Machine
Start the Virtual Machine
Getting the Libraries
Add the PPA for libmysqlclient15off, a pre-requisite for APE Server:
username# gpg --keyserver hkp://keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A
username# gpg -a --export CD2EFD2A | apt-key add -
sudo sh -c 'echo "deb http://repo.percona.com/apt maverick main" >> /etc/apt/sources.list.d/percona.list'
Install libmysqlclient15off
sudo apt-get update; sudo apt-get install libmysqlclient15off
Get and install the latest version of APE server
Edit /etc/network/interfaces, and add the following to the end:
auto eth0
iface eth0 inet static
address 192.168.56.101
netmask 255.255.255.0
Close the virtual machine and go into its settings. Change the network settings for the first interface to Host-only Adapter
Setting Up APE
Restart the Virtual Machine, and ensure that the APE daemon is running
username# ps -ef | grep "aped"
If you need to, make changes to /etc/ape/ape.conf
Final Steps
Add the following to your hosts file, or some variation:
192.168.56.101 local.site.com
192.168.56.101 0.local.site.com
192.168.56.101 1.local.site.com
192.168.56.101 2.local.site.com
192.168.56.101 3.local.site.com
192.168.56.101 4.local.site.com
192.168.56.101 5.local.site.com
192.168.56.101 6.local.site.com
192.168.56.101 7.local.site.com
192.168.56.101 8.local.site.com
192.168.56.101 9.local.site.com
Access your new APE server via local.site.com:6969
Check APE config file. Are you binding to the right IP ? By default it's 127.0.0.1