[cowdancer] 01/01: qemubuilder: Add support for arm64
James Clarke
jrtc27-guest at moszumanska.debian.org
Mon Oct 17 21:42:43 UTC 2016
This is an automated email from the git hooks/post-receive script.
jrtc27-guest pushed a commit to branch master
in repository cowdancer.
commit bb7130a166a4b2bdddab018a8f2d8f99db7e09c4
Author: James Clarke <jrtc27 at jrtc27.com>
Date: Mon Oct 17 22:42:34 2016 +0100
qemubuilder: Add support for arm64
Closes: #838753
---
qemuarch.c | 44 +++++++++++++++++++++++++-------------------
qemuarch.h | 1 +
qemubuilder.c | 48 +++++++++++++++++++++++++++++++-----------------
3 files changed, 57 insertions(+), 36 deletions(-)
diff --git a/qemuarch.c b/qemuarch.c
index 8351e9c..3f90b8e 100644
--- a/qemuarch.c
+++ b/qemuarch.c
@@ -58,14 +58,12 @@ const char* qemu_arch_diskdevice(const struct pbuilderconfig* pc)
if (!strcmp(arch, "arm") ||
!strcmp(arch, "armel") ||
- !strcmp(arch, "armhf"))
- {
- consoledev = makedev(204, 64);
- }
+ !strcmp(arch, "armhf") ||
+ !strcmp(arch, "arm64"))
+ consoledev = makedev(204, 64);
else
- {
- consoledev = makedev(4, 64);
- }
+ consoledev = makedev(4, 64);
+
return mknod_inside_chroot(basedir, "dev/console", S_IFCHR | 0660, consoledev);
}
@@ -116,18 +114,17 @@ const char* qemu_arch_qemu(const char* arch)
if (!strcmp(arch, "arm") ||
!strcmp(arch, "armel") ||
!strcmp(arch, "armhf"))
- {
- return "qemu-system-arm";
- }
- if (!strcmp(arch, "mips"))
+ return "qemu-system-arm";
+ else if (!strcmp(arch, "arm64"))
+ return "qemu-system-aarch64";
+ else if (!strcmp(arch, "mips"))
return "qemu-system-mips";
else if (!strcmp(arch, "mipsel"))
return "qemu-system-mipsel";
else if (!strcmp(arch, "i386")
|| !strcmp(arch, "hurd-i386")
|| !strcmp(arch, "amd64")
- || !strcmp(arch, "x32")
- )
+ || !strcmp(arch, "x32"))
{
/* we're leaking this memory, but don't care too much */
char* host_arch = get_host_dpkg_arch();
@@ -166,8 +163,9 @@ const char* qemu_arch_qemumachine(const char* arch)
if (!strcmp(arch, "arm") ||
!strcmp(arch, "armel"))
return "versatilepb";
- else if (!strcmp(arch, "armhf"))
- return "virt";
+ else if (!strcmp(arch, "armhf") ||
+ !strcmp(arch, "arm64"))
+ return "virt";
else if (!strcmp(arch, "i386") ||
!strcmp(arch, "hurd-i386") ||
!strcmp(arch, "amd64") ||
@@ -191,10 +189,18 @@ const char* qemu_arch_tty(const char* arch)
if (!strcmp(arch, "arm")||
!strcmp(arch, "armel") ||
- !strcmp(arch, "armhf"))
- {
- return "ttyAMA0,115200n8";
- }
+ !strcmp(arch, "armhf") ||
+ !strcmp(arch, "arm64"))
+ return "ttyAMA0,115200n8";
return "ttyS0,115200n8";
}
+/**
+ * arch-specific routine; the CPU
+ */
+const char* qemu_arch_cpu(const char* arch)
+{
+ if (!strcmp(arch, "arm64"))
+ return "cortex-a57";
+ return NULL;
+}
diff --git a/qemuarch.h b/qemuarch.h
index 12d989e..f8eee9c 100644
--- a/qemuarch.h
+++ b/qemuarch.h
@@ -14,5 +14,6 @@ char* get_host_dpkg_arch();
const char* qemu_arch_qemu(const char* arch);
const char* qemu_arch_qemumachine(const char* arch);
const char* qemu_arch_tty(const char* arch);
+const char* qemu_arch_cpu(const char* arch);
#endif
diff --git a/qemubuilder.c b/qemubuilder.c
index 4f94b35..fdf8b26 100755
--- a/qemubuilder.c
+++ b/qemubuilder.c
@@ -519,10 +519,12 @@ static int fork_qemu(const char* hda, const char* hdb, const struct pbuilderconf
/* this is the child process */
const char* qemu = qemu_arch_qemu(pc->arch);
const char* machine = qemu_arch_qemumachine(pc->arch);
+ const char* cpu = qemu_arch_cpu(pc->arch);
const char* hda_format = format_for_image(hda);
const char* hdb_format = format_for_image(hdb);
char* hda_command;
char* hdb_command;
+ int virt;
char* append_command;
const char* kernel_image = pc->kernel_image;
const char* initrd = pc->initrd;
@@ -566,12 +568,16 @@ static int fork_qemu(const char* hda, const char* hdb, const struct pbuilderconf
exit(1);
}
+ virt = !strcmp(machine, "virt");
+
asprintf(&hda_command,
- "file=%s,format=%s,index=0,media=disk,cache=writeback,id=hd0",
+ "%sfile=%s,format=%s,index=0,media=disk,cache=writeback,id=hd0",
+ virt ? "if=none," : "",
hda, hda_format);
asprintf(&hdb_command,
- "file=%s,format=%s,index=1,media=disk,cache=writeback,id=hd1",
+ "%sfile=%s,format=%s,index=1,media=disk,cache=writeback,id=hd1",
+ virt ? "if=none," : "",
hdb, hdb_format);
/* panic < 0 means reboot immediately on panic; this will actually
@@ -592,6 +598,11 @@ static int fork_qemu(const char* hda, const char* hdb, const struct pbuilderconf
argv[argc++]="-no-reboot"; /* halt instead of rebooting */
argv[argc++]="-M";
argv[argc++]=strdupa(machine);
+ if (cpu)
+ {
+ argv[argc++]="-cpu";
+ argv[argc++]=strdupa(cpu);
+ }
argv[argc++]="-m";
argv[argc++]=mem;
if (pc->smp) {
@@ -622,21 +633,24 @@ static int fork_qemu(const char* hda, const char* hdb, const struct pbuilderconf
}
argv[argc++]="-net";
argv[argc++]="user";
- if (!strcmp(machine, "virt")) {
- argv[argc++]="-device";
- argv[argc++]="virtio-scsi-device,id=scsi";
- argv[argc++]="-device";
- argv[argc++]="virtio-net-device,netdev=net0";
- argv[argc++]="-device";
- argv[argc++]="scsi-hd,drive=hd0";
- argv[argc++]="-device";
- argv[argc++]="scsi-hd,drive=hd1";
- argv[argc++]="-netdev";
- argv[argc++]="user,id=net0";
- } else {
- argv[argc++]="-net";
- argv[argc++]="nic";
- }
+ if (virt)
+ {
+ argv[argc++]="-device";
+ argv[argc++]="virtio-scsi-device,id=scsi";
+ argv[argc++]="-device";
+ argv[argc++]="virtio-net-device,netdev=net0";
+ argv[argc++]="-device";
+ argv[argc++]="scsi-hd,drive=hd0";
+ argv[argc++]="-device";
+ argv[argc++]="scsi-hd,drive=hd1";
+ argv[argc++]="-netdev";
+ argv[argc++]="user,id=net0";
+ }
+ else
+ {
+ argv[argc++]="-net";
+ argv[argc++]="nic";
+ }
argv[argc]=NULL;
assert(argc < MAX_ARGS);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pbuilder/cowdancer.git
More information about the Pbuilder-maint
mailing list